wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes send file from client to server using serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "send file from client to server using serialization" Watch "send file from client to server using serialization" New topic
Author

send file from client to server using serialization

Nitesh Pandey
Greenhorn

Joined: Aug 30, 2011
Posts: 2
hey...i want to write a program to send file from client to server using serialization...bt i am facing problem when client send the file to server it does not send the file with content...what would be problem..please help me regarding this my client code is:::



Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

Hi Nitesh,

Welcome to Java Ranch! I just have a couple of administrative points to get you started. First, when asking a new question, it's best to start it in a new thread. I've split this one off for you. Also, when posting code, it's good to use code tags. Just press the Code button above the edit window, and then past in your code between the tags it generates. It will make your code much easier for us to read.

Now, I think your problem is that serializing the File object is not the same as writing the contents of the file. I assume you have a Server class running on the server or nothing would work at all, so you just have to change the part where you serialize via writeObject() and readObject() to reading the file contents and writing them to the the socket on the server, and reading from the socket and writing to a file on the client. Look into the classes java.io.FileInputStream and java.io.FileOutputStream to get started.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: send file from client to server using serialization
 
Similar Threads
Establishing two-way buffered streams
Send a file across the network
Error performing inpage operation
File from ObjectInputStream through Socket
SocketPermission