posted 20 years ago
So, I was wondering, could I split a single file variable into multiple file variables that points to a different section of the same file?
I don't think so. What do you mean by "file variable"? A File object? A RandomAccessFile? A FileInputStream? Something else? These all refer to the whole file, not just part of it.
I think the key is that you're trying to put all the bytes into one big array at once. You don't have to do this. You can use a smaller byte[] array, and keep re-using it. Read some bytes to fill the array, write those bytes to the new file, then read some new bytes into the array (overwriting the ones previously stored there), and write those to the new file. Repeat until done.
If you're using JDK 1.4 there's a much faster way to do this using FileChannels. But I'm guessing for a class they probably want you to figure out how to do this with streams first.
"I'm not back." - Bill Harding, Twister