I'm trying to design an open source, java based download module. I'm still in the proof of concept stage though. I've made the code necessary to download a file, but to test the resume feature, I would terminate the process before the download finished and then restart it. But when it restarts, it deletes the file and makes a new one in it's place. Here is my code so far:
Does this make sense? According to the code, this is not a clear resume, but the client skips just the portion it has already received. But in each case you re-read the file from the beginning. So if you're connection is interrupted after transferring n GB, you got the retransmit them all in each case, just the client picks the the bytes it needs from that big piece already retransferred. This doesn't save neither time nor bandwith. Am I wrong here?
IMHO, the only approach of resuming a download can be initiated by the server, by giving it the start position in the target file it should start sending at.
Charles Mulloy wrote:Found the problem.
First off, line 31 is useless. It is from a past attempt and I forgot to remove it, so ignore it altogether.
Second, the error is in line 24. I constructed the FileOutputStream wrong. I used...
This will delete the file if it exists. But this...
... will make it append to the end.
The final product (before I start adding stuff):
@Amit: I only wanted to give credit where it was due. I had code before seeing this link, but it wasn't working like I wanted. What I have now is a derivative of the code found there.