General discussion

Locked

File Transfer In Java (Resumable)

By basit_jafri ·
Hi

I wanna make an application to transfer file from one system to another, direcly, i mean peer to peer (no servers). How can i do that, what api should i use, what classes,

Any Ideas???/

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

File Transfer In Java (Resumable)

by Jay Eckles In reply to File Transfer In Java (Re ...

java.net.Socket would be a good place to start. You'll also need java.io.File and other java.io classes for reading/writing to a file. You might use java.io.BufferedInputStream, I'm not sure how you want to do things.

To make the transfer resumable, the only thing I can think of immediately is to count the number of bytes that you've written previously, tell the sending program that you've already received the first x bytes, and it will skip those and start sending at x+1 bytes. Then append whatever it sends you to the incomplete file.

I would start with one of the many freely available Java FTP servers and clients. They will have much of the functionality you need, and you can pick and choose what code to re-use. You can use such a program to learn how to open a file and send it over a network connection.

Good luck.

Jay
www.jayeckles.com

Collapse -

File Transfer In Java (Resumable)

by basit_jafri In reply to File Transfer In Java (Re ...

Thanx man, u gave the most appropriate answer

Collapse -

File Transfer In Java (Resumable)

by zeshanzia In reply to File Transfer In Java (Re ...

To transfer files between two systems there is a very easy trick, and a programming trick.

1. Programming Trick:- Use File class method "renameTo" note that if Source and Destination are same it will rename your file, otherwise it will move your file from source to destination. (I used word "Move" not "Copied")

2. As you might need to Move file in other systems, if you have local Intranet then MAP the Folder of destination At Source (Windows)

OR

3. Use this sort of path as destination "//172.0.0.0/SharedFolderName" where first one is destination IP

4. At the Next Line of renameTo function, check whehter source exist through "exists()" function. If it is it means that the file movement is terminated due to some network problem and you can do the task AGAIN.

Rate this answer, if it helps

Collapse -

File Transfer In Java (Resumable)

by basit_jafri In reply to File Transfer In Java (Re ...

thanx anyways man, but ur answer was'nt good enough, u know what, im looking for a more generic solution, something working as peer 2 peer file sharing thing

Collapse -

File Transfer In Java (Resumable)

by basit_jafri In reply to File Transfer In Java (Re ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums