wood burning stoves 2.0*
The moose likes Java in General and the fly likes upload and download file to any machine in a n/w Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "upload and download file to any machine in a n/w" Watch "upload and download file to any machine in a n/w" New topic
Author

upload and download file to any machine in a n/w

taher hussain
Greenhorn

Joined: Mar 17, 2008
Posts: 5
i need a code snippet that can read any file in a network, and the make changes to that file. this file could be any file. the code that i have written functions only when the particular directory is shared in the network.
in clear words a need a utility that can read a file from one of the client m/c and then save it to the host. later we should be able to read the file from the server and download it back to the client.
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Taher Hussain,
Welcome to JavaRanch.

Originally posted by taher hussain:
utility that can read a file from one of the client m/c and then save it to the host. later we should be able to read the file from the server and download it back to the client.


Well, the InputStream and OutputStream classes (and their descendents like FileInputStream and FileOutputStream)are typically meant for the purpose of reading and writing files respectively.

the code that i have written functions only when the particular directory is shared in the network.

The simple thing is :if you don't have access to a resource you can't access it, for reading as well as writing. There are a few gotchas but, you should not get into them.

i need a code snippet

Do serious googling to get hold of them instead of asking for the code directly. If you have any problems implementing the code, let us know what the problem is and we'll be more than happy to assist.
taher hussain
Greenhorn

Joined: Mar 17, 2008
Posts: 5
Originally posted by Anubhav Anand:
Taher Hussain,
Welcome to JavaRanch.


Do serious googling to get hold of them instead of asking for the code directly. If you have any problems implementing the code, let us know what the problem is and we'll be more than happy to assist.
taher hussain
Greenhorn

Joined: Mar 17, 2008
Posts: 5
i'll explain what i do and the error i get-
the client opens a file dialog box to select a file. the complete path i pass to the upload servlet using request. when i use it to create an object of FileInputStream - it throws the following exception.....

java.io.FileNotFoundException: (The network path was not found)

if the directory is shared in the n/w, i do not get this exception and i can read the file. same is the case with downloading the file back to the client. if the directory in which the file is uploaded is shared then only can the client download it. i need an application that can read or write a file to a machine in a network irrespective of its shared status. authentication should not be a problem.

thanks in advance
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Originally posted by Anubhav Anand:
The simple thing is :if you don't have access to a resource you can't access it, for reading as well as writing. There are a few gotchas but, you should not get into them.


Did you read my post carefully. I specified very clearly that if you don't have access then you can't go ahead.

But,now if anyway you have to go ahead then one solution can be to make a hosted wev client. Now, whenever you want to read/write files to a client you'll have to talk to your web server and it will appropriately do the job. Thus, it will require to have some sockets open to listen to your request and do the according job which will be kind of upload/download to a client machine. But, even in tis case your server must have administrative rights.

Hope that helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: upload and download file to any machine in a n/w