I am trying to divide a binary file (like video/audio/image) into chunks of 100kb each and then join those chunks back to get back the original file. My code seems to be wor
I can spot only 2 potential mistakes in the code:
int fileSize = (int) ifile.length();
The above fails when the file is over 2GB since an int cannot hold more.
newName = fname + ".part" + Integer.toString(nChunks - 1);
A filename which is constructed like that should be sorted on a very specific manner. When using default string sorting, name.part10 will namely come before name.part2. You'd like to supply a custom Comparator which extracts and parses the part number as an int and then compare by that instead.