• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic