I am downloading file parts using socket, saving them as .part1, .part2 etc.( However I am not sure if I should). I am trying to merge them in a .bin fil开发者_运维问答e. Can any of you recommend me a way to do that? Should I read them all as binary and then append it? I don't even know if that makes sense actually.
Why don't you open the first part for input, and open an output streamof the form
out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));
then read in your first part file as bytes, and use the writeByte() method to write it all out.
Then close the first part, open the second part, and read it in, then out to the output file.
Will that not merge the contents of the two files?
I did it. Read files one by one and wrote them to output.
精彩评论