• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access files on a remote computer?

 
Dan Mortimer
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've written the following method, which retuns an array of Strings containing the names of all the files (and directories) in the location I specify when constructing the File object:

private String[] getMatchingFiles() {
File dir = new File("c:\\temp");
return dir.list();
}

This works just fine when I specify locations on my local machine, but what I'd like to be able to do is specify a location on a remote computer.

Could someone please let me know how to create a File object that points to a directory on another pc?

Thanks!
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The remote computer has to allow access on it's files and provide a service, to get them.

If it's running an ftp-server, you can get the file by ftp.
If it's running windows, I don't know exactly, but I would look, how the files show up in the explorer, especially the part, where the foreign machine is specified, and try it that way.
When I remember correctly, it is something like
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!