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

Transfer file from a client to server

Java Networking
Greenhorn

Joined: Oct 19, 2003
Posts: 1
I wrote a client server program where client send request and reciev reply and the server makes connection for each client and tehn echoes the client request.
I want to modify this program too send a file from client to server.
How can i do that any help will be appreciated.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi J.N.,
Welcome to JavaRanch!
We ain't got too many rules round these parts, but we do have our naming policy. Your display name can't be an obvious fake, like your'n. Thank you kindly for hot-footin' it over here to fix yours up!
Now, on to your question.
If you've written the echo server you've described, I'm not sure why you'd have a problem with transferring a file. Just open the file and spit all the data through the connection. Of course, the server has to be waiting for it. To make life easier, you might want to send the file name and file size first, and have the server be expecting that, too.
Be sure to use InputStreams and OuputStreams, not Readers and Writers, to transfer the data, or your program won't work for non-textual files.


[Jess in Action][AskingGoodQuestions]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Robert Martin has been writing a series about sending compile jobs to a server - send source and get back listings and class files. It has some neat ideas about wrapping files in objects for socket transfer. See if somebody has a stack of Software Development magazines, or try http://www.sdmagazine.com/columnists/martin/ online. His ObjectMentor.com site is not responding right now, but if it comes back the articles are there, too.


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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transfer file from a client to server