Java access to LAN shared resources

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.