posted 17 years ago
It looks like the byte[] array "data" contains the entire content of the file. If the file is too big, then that array will be too big. So if there's any way to avoid putting all the data in a single byte[] at one time, do it. For example, you might grab a little bit of the stream at a time, and write the data from the stream to a file:
Here we still use a byte[] array, but its size is limited to 4096. We just keep filling it and writing it as many times as necessary.
It really depends on what you need to do with the data. Often it's possible to process the data in small chunks, as above. Other times it's much easier to have all the data in memory at once. But for large files, try to avoid putting all the data in memory at once.
[ April 26, 2007: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister