本文介绍了拆分二进制文件,将数据添加到每个块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在其中我有一个二进制文件转换成一个自定义的文件格式,这就需要分割文件中添加一些数据,然后将其重新打包为新文件的项目工作。

I have to work on a project in which I have to convert a binary file into a custom file format, which requires splitting the file adding some data to it and then repacking it into the new file.

例如

我有1 MB的文件,我必须把它分割成固定长度的数据块,然后加入一些数据作为头吧。
之后,整个文件将被重新包装成一个新的文件中。

I have a file of 1 MB and I have to split it into chunks of fixed length and then adding some data as a header to it.After that the entire file will be repackaged into a new file.

请任何帮助将AP preciated。

Please any help will be appreciated.

推荐答案

首先,你使用的读的X字节块为单个字节数组,其中x是块大小。我建议将这些字节数组存储在一个创建新的文件。

Then you create a DataOutputStream for creating the new file.

最后,你遍历一个for循环的ArrayList和数组的内容写入DataOutputStream类,preceded或之后的附加数据,您需要添加对每个块。

Finally, you iterate over your ArrayList with a for loop and write the contents of the arrays to the DataOutputStream, preceded or followed by the additional data you need to add for each chunk.

我希望我能够帮助你。当事情不清,随意问。

I hope I was able to help you. When something is unclear, feel free to ask.

这篇关于拆分二进制文件,将数据添加到每个块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 16:29