Local to read a file on another computer, the two hosts on the same LAN, copying each other time consuming effort. You can read the file from other hosts on your LAN by simply setting the resource you want to access to a resource share.
First, set the folder where the files will be accessed to shared folders.
The next step is to access:
public class Testtelnet {public static void main (string[] args) {//TODO auto-generated method stub file = new Fi Le ("\\\\royal-pc\\thinkinjava"); file[] Lists = File.listfiles (); for (File file1:lists) { System.out.println (File1.getname ());}}}
Results:
Javaio.docx
Java common. docx
java concurrency. docx
Synchronized vs Lock.docx
Think in Java.docx
Threadpool.docx
~ $ink in Java.docx
Class loader. docx
design mode. docx
Read the configuration file. docx
Process and thread. docx
The file path is "\\\\royal-pc\\thinkinjava", ROYAL-PC is the host name of the other, and can be accessed with an IP address. The escape character "\" is required before the address delimiter.
Java access to LAN shared resources