Solved the problem.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Solved the problem.
Last edited by LDM91; March 3rd, 2011 at 02:18 PM. Reason: [SOLVED]
Do you have some code we could look at? It's difficult to diagnose the problem without it.
I don't understand your problem,but let's assume that we have those streams:
in:the input stream from server
out: the output stream to server
outfile: the output stream to file.
I suppose that you have already created them.
now let's download that file:
int i;//number of received bytes byte []data=new byte[100];//byte array to hold data //now: while((i=in.read(data))!=-1){ outfile.write(data,0,i); outfile.flush(); } in.close(); outfile.close(); out.close();
the line :
outfile.write(data,0,i); means : only write the bytes that I have just read and not more(those bytes are from 0 to i).
I hope this may help you.
Solved the problem.
Last edited by LDM91; March 3rd, 2011 at 02:19 PM. Reason: [SOLVED]
Solved the problem.
Last edited by LDM91; March 3rd, 2011 at 02:19 PM. Reason: [SOLVED]