V
V
Vlad1612014-02-05 12:34:17
Java
Vlad161, 2014-02-05 12:34:17

Resume file, write method

I am making a client-server application, downloading a file from the server to the client. You need to download the file. That is, for example, a 50mb file, downloaded 20 and broke off, with the next jump of this file, it downloaded the remaining 30mb, and did not download the file again.
Going into the off-line documentation, I saw this:

public abstract void write(char[] cbuf, int off, int len)

Given that off - Offset from which to start writing characters, , that is, off is an int number from where to start downloading the file. I tried to do this: Check if there is such a file on the client, transfer the value to the server, and it, in turn, starts downloading the file, that is, transfer the missing one. Looks like this
os.write(mybytearray, (int) clientFileSize, n); //server
bos.write(mybytearray, (int) clientFileSize, bytesRead); //client

So the question is, what is the solution? Will it work correctly, and when connected, resume the file, or will it write the same thing every time in the while loop? I quickly checked, the resume seems to be going on, I haven’t done a full test yet.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fat Lorrie, 2014-02-05
@Free_ze

Will do. Just keep in mind that len ​​= fileSize - clientFileSize.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question