send file from client to server using serialization
posted 4 years ago
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:::
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.