my dog learned polymorphism*
The moose likes Sockets and Internet Protocols and the fly likes name of file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "name of file" Watch "name of file" New topic
Author

name of file

manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Hi,
I transfer a file from a client to a server. It works fine. But the client transfer only data. How can I solve transfer with name of file?(I use ServerSocket, Socket, OutputStream, InputStream)

Thanks for your help
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
What does "transfer with name of file" mean?. What else is there to transfer except for the data of the file (which you said works fine)?


Ping & DNS - updated with new look and Ping home screen widget
manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Originally posted by Ulf Dittmer:
What does "transfer with name of file" mean?. What else is there to transfer except for the data of the file (which you said works fine)?



I transfer only data of file without filename. File > FileInputStream > BufferedInputStream > .... via OutputStream to net(tcp)

For example:
client binary.bin ... transfer file from parameter

but on server side I create my own name of file. I don't know how get filename of file which is send by client.
manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Originally posted by manu chao:



I transfer only data of file without filename.

Client : File > FileInputStream > BufferedInputStream > .... via OutputStream to net(tcp)

For example:
client binary.bin ... transfer file from parameter

but on server side I create my own name of file. I don't know how get filename of file which is send by client.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Before sending the data, can you send the file name over the same stream, with some pre-determined marker to separate the file name from the file data?
manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Originally posted by Ulf Dittmer:
Before sending the data, can you send the file name over the same stream, with some pre-determined marker to separate the file name from the file data?


Yes, I can. And is it the best way?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
That's hard to say without knowing the circumstances. So far we only know that you have a single stream to work with.
manu chaox
Ranch Hand

Joined: Apr 10, 2006
Posts: 110
Originally posted by Ulf Dittmer:
That's hard to say without knowing the circumstances. So far we only know that you have a single stream to work with.


I tried solution sending filename in first block.

But is it possibility to use ObjectInputStream, ObjectOutputStream for sending filename by any way?

Client:
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Why do you want to use object streams?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: name of file
 
Similar Threads
How do I transfer a text file from server to client?
how to Transfer a file/jar to another Computer
Chat Client and file transfer
How to transfer XML file generated at client side in Struts 1.3 to MySQL Server specific path?
Which one is good among Polling / Proxies / Callback implementation in Asynchronous call?