1

Is it possible for a JAVA application to get the file system directory structure of another host on the same LAN?

For example:

Machines A and B are on the same LAN. A is the localhost and B is the remote host. Is it possible for a JAVA application executing on A to get the directory structure (essentially a 'ls -R') of B?

yoozer8
  • 7,361
  • 7
  • 58
  • 93
czchlong
  • 2,434
  • 10
  • 51
  • 65

2 Answers2

1

Yes, although you'd have to use something like SSH to open a remote terminal session to execute the ls command. There's no way to natively do that with just Java without opening a socket and machine B somehow cooperating with the request. (That would be a huge security hole if you could...)

Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
1

One way to do this is by issuing the ls -R command over the ssh protocol.

For ssh library recommendations, see SSH library for Java

Community
  • 1
  • 1
NPE
  • 486,780
  • 108
  • 951
  • 1,012