For a specific separation, you must follow these steps.
1] Calculate No from the section can be done using this file.
So, if you want each part to be 300 KB in size ...
calculeteParts=(long)(fsize/(300));//As fsize already in KB in your program.(FOR FILE IN MB)
2] In order to make No of Parts, say, from file f, we can make 30 patches of 300 KB in size.
while((readInt = fin.read(b))!= -1) { fout.write(b, 0, readInt); e+= readInt; if(e==300*1024)//if Read 300 Upcoming KBs done { e =0L; fout.close(); doPart(); } }
But the most important thing
THE PROBLEM TO BE SOLVED
Say you have a 9.04 MB file and you want to split it into 300 KB partitions. Therefore, when programming this, you will have to make it several 300 KB.
Example.
9.04*1024=9256.46KB So total of 9256KB approximately Now Divide it with your needed size 9256/300=30.85 so approximately 30 parts. So 0.85 will be lost Or if you take **31**: 300*31=9300 which is greater than 9256
doParts(); , which is called recursively, so in a LAST PART, which CANNOT be up to 300 KB, it will read to a possible value, but after that it Stream Closed:IOEXception throw a Stream Closed:IOEXception Eventough, although this does not matter to you. p>
coder-croc
source share