In my project i need to split a zipfile of any size into 1MB files and then merge it to get the original file.My java code works fine upto 58MB zipfile but for the file size greater than 58MB i get the following exception
There is definitely a maximum. Memory used by JVM cannot be higher than what the OS allows to allocate.
Heap size should also be somewhat smaller than total RAM since otherwise garbage collection will cause trashing (slowing down entire system very badly).
It is possible to split arbitrary large file without need for large memory.
Joined: Jan 23, 2008
Don't try to read the entire file into memory. Read a small chunk, write it out and repeat.
i didnt get your concept.actually i need to get the file length and then split that file into 100kb file and pass it to queue and from queue another program collects that files and merge all that splitted files into one file to get the original file size.here how to do as you have told. do help me if you have any suggestions. thanks in advance Latha
read 100kb and write it to a file. Do that over and over until the input stream ends.
and pass it to queue and from queue another program collects that files
Presumably you are doing this now with the files you are creating. Nothing would change.
and merge all that splitted files into one file to get the original file size.
I'm unclear as to whether your program is merging the files, or if the other program is. If your program has to do it, it is simply the reverse of splitting the files. Open an output stream and read each of your 100kb inputs in turn.
subject: is it possible to process a 500MB zipfile in java?