aspose file tools*
The moose likes Java in General and the fly likes The best way to transfer files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "The best way to transfer files" Watch "The best way to transfer files" New topic
Author

The best way to transfer files

Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
Hello
I know how to make clients and servers using TCP/IP and so on
How can I transfer file from one computer to other with Java? what is the best way to make is really quick and not read line by line and so on?
Tank for the help
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I'd Google for a "Java FTP" package and use the FTP APIs. It would be fun to write your own over sockets, but an existing package would represent an awful lot of problems already solved.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
The point is that I don't want it to be FTP
I just want the server to get a client full path and then download this file from his computer
Like point to poing transfer
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

Originally posted by Oz Kron:
The point is that I don't want it to be FTP
Okay. Then what protocol do you want to use instead? You can't just download a file from somebody else's computer unless that computer has a server that is running and willing to give you the file.
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
Well
Maybe I wasn't clear enouth
Let's say my friend is running a server java program I have sent him
I know it's IP and I have the client
How can I download form him?
Just how to make a simple server-client programs to make it possible?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
Just how to make a simple server-client programs to make it possible?


Yes, it's possible, but you need to agree on a protocol on how to transfer the data. Of course you can roll your own, but that's like reinventing the wheel, because you're going to have to solve a lot of problems that have been solved by FTP and other protocols already.
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
The point is that I don't want something too much sophisticated or something like that
Just plain and simple
Can you give me an exmaple for this please?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

I don't think I am getting your requirements correctly. Let me ask this: is your goal to get something useful done, or is your goal to learn about programming by writing a program?
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
I want both
To learn and to write a program
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Cool! Then we'll switch from the most efficient mode (like I was paying you by the hour) to having some fun and getting it done.

Have you run through the Sun Networking Tutorial? It's really quite good and should get you sending data back and forth with sockets. Reading and writing that data from files is easy to add on once you have things going.

The "Knock Knock Protocol" in the tutorial is an example of a protocol, which is simply a set of rules about what you send each way. A conversation for file transfer might look like:

Client->Server GET FILE name.ext
Server->Client SENDING FILE name.ext nnnnn bytes
Server->Client bytes ....

or

Client->Server GET FILE name.ext
Server->Client ERROR 123 FILE NOT FOUND

Work through the tutorial, take a shot at it in your own code, let us know if you get stuck.
[ April 03, 2007: Message edited by: Stan James ]
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
Yep I know this way, but it seem very slow and not effective, can't I do better?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: The best way to transfer files