How to break a file into pieces using Java?

前端 未结 2 2101
轮回少年
轮回少年 2020-12-04 20:40

I got a kind of weird question to ask. I need to know how can I break a given file into small small pieces using Java (any file type). Then I can put those peaces into numbe

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 20:50

    Read & write streams as raw byte[]. Avoid the text streams and readers.

    In your last question your were apparently breaking up the files according to 'line'. To replicate that behavior, simply used a fixed size of byte[] to read. Note carefully the warnings in comments to your last question, to check how many bytes are read. A byte[2^16] will not necessarily be filled in a single read.

提交回复
热议问题