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,194
  • 6
  • 53
  • 88
czchlong
  • 2,354
  • 10
  • 48
  • 63

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
  • 34,318
  • 11
  • 78
  • 107
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
  • 464,258
  • 100
  • 912
  • 987