Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read a file from remote system using java?

I have a file copied in one computer and I need to access the file from other computer. I am not sure, which protocol or which technology to use for this? Please provide me any hints for this..

Update:

I am using Ubuntu Linux system. I used the code :

File f = new File("//192.168.1.157/home/renjith/picture.jpg");// 192.168.1.157 is the ip of the computer, where I have the picture file
Image image = ImageIO.read(f);

But it is giving an exception:

javax.imageio.IIOException: Can't read input file!
    at javax.imageio.ImageIO.read(ImageIO.java:1275)

I have shared renjith folder also.

like image 280
user236919 Avatar asked Jan 06 '10 06:01

user236919


1 Answers

There are any number of ways to access files on remote machines, but they virtually all depend on the remote machine having been set up to provide the file in some way first. If you with to access files via java, the easiest method would probably be to set up an HTTP server on the remote machine (this can be done pretty easily using Apache HTTP server on a variety of platforms) and then using Apache Commons HTTPClient on the client side java app. Further discussion of how to install these or configure them is generally beyond the scope of Stack Overflow and would at least require a more specific question

like image 137
Jherico Avatar answered Sep 19 '22 05:09

Jherico