连接分割文件算法 [英] Join Split File Algorithm

查看:64
本文介绍了连接分割文件算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想编写一个简单的程序来连接和拆分文件(例如,扩展名为.001).我知道有可用的程序,但是我对了解算法以及自己编写实际程序很感兴趣.

感谢您的帮助.

Hi,

I would like to write a simple program to join and split files ( for example with extension .001). I know that there are programs available but I''m interested in knowing the algorithms as well as writing an actual program myself.

Thanks for your help

推荐答案

文件是字节流.如果要拆分或合并它们,只需将适当的数据写入文件系统.如果要合并或拆分特定的文件格式,从而使文件仍然可以工作,则可能会更复杂.
A file is a stream of bytes. If you want to split or join them, you just write the appropriate data to the file system. If you want to join or split specific file formats, so the files still work, then it might be more complex.


算法很简单:可以打开以读取原始文件,然后读取CHUNK(CHUNK是您的魔术预定义常数)字节,并写入第一个输出文件,例如``out.001''.重复此操作,直到无法从原始文件读取更多字节.
对于加入,请执行相反的操作(注意:您具有文件名的有序列表).
Well, the algorithm is simple: open for reading the original file, read CHUNK (CHUNK is your magic predefined constant) bytes and write to first output file, e.g. ''out.001''. Repeat such operation until you cannot read more bytes from the original file.
For joining just do the opposite (note: you have an ordered list of file names).


这篇关于连接分割文件算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆