• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The best way to transfer files

 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want both
To learn and to write a program
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep I know this way, but it seem very slow and not effective, can't I do better?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic