aspose file tools*
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: 42944
    
  68
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)?
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: 42944
    
  68
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: 42944
    
  68
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: 42944
    
  68
Why do you want to use object streams?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: name of file