Java - 分隔两个gzip字符串
我有两个字符串。例如“苹果”和“牛顿”。我分别使用 gzip 压缩它们,然后加入生成的 gzip 字符串并存储在文件中。然后我检索文件中的内容。当我将整个字符串解压在一起时,我得到了确切的结果。但我想找到每个 gzip 压缩字符串的 EOF。这可能吗。
这是必需的,因为我存储了大量垃圾数据。我使用缓冲区大小进行检索。当我直接尝试解压缩时,出现 EOFException。如果我能够获得 EOF,我可以截断不需要的部分,然后解压缩所需的内容
I have two Strings. For example "apple" and "newton". I compress them using gzip separately and join the resultant gzipped strings and store in a file. Then I retrieve the content in the file. When I unzip the total string together I get the exact result. But I want to find the EOF of each gzipped String. Is this possible.
This is required because I store large junk of data. i retrieve using a buffer size. When I directly try to unzip I get EOFException. If I am able to get the EOF I can truncate the unwanted part and then unzip the required content
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在连接两个字符串之前使用任何分隔字符(例如空格或逗号),以便您可以识别每个字符串的结尾。
当您将整个字符串解压在一起时,您将得到类似“apple,newton”的结果,
现在使用 String 类的 split() 方法来获取各个字符串。
Use any delimiting character before joining the two strings, for example a space or a comma, so that you can recognize the end of each string.
when you will unzip the total string together, you will get result like this "apple,newton",
Now use split() method of String class to get the individual strings.
您可以将“apple”、“newton”存储为两个单独的 String 对象,并用另一个对象来分隔这两个对象。当你读取对象时,你可以比较对象是什么类型。这样您就可以轻松找到分隔符对象。
You can store "apple", "newton" as two separate String objects with another object to separate this two. When you read object, you can compare what type of object. This way you can find separator object easily.
充气器有一个 isFinished() 方法,该方法在边界处停止。我基本上编写了一个类来扩展 GzipinputStream 并获取 inflater 对象。每当有一个已完成的零件流时,isFinished 都会返回 true。你可以继续阅读或停在那里
The inflater has a method isFinished() which stops at boundaries. i basically wrote a class to extend the GzipinputStream and get back the inflater object. Whenever there is a part stream which is completed isFinished returns true. you can either continue reading or stop there