我想问局域网中联网的电脑10.1.1.10 c盘下test.txt
C盘的共享名为 C$.File f = new File("file:///10.1.1.10/C$/test.txt"),不行File f = new File(new URI("file:///10.1.1.10/C$/test.txt")),不行File f = new File("\\\\10.1.1.10\\C$\\test.txt"),不行File f = new File("File:\\\\10.1.1.10\\C$\\test.txt"),不行那怎样才行呢?多谢各位!

解决方案 »

  1.   

    File f = new File("file://10.1.1.10/C$/test.txt"),不行File f = new File(new URI("file://10.1.1.10/C$/test.txt")),不行
      

  2.   

    public void access() throws Exception {
    File file = new File("\\\\192.168.1.104\\aa\\a.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
    String s = null;
    while ((s = br.readLine()) != null) {
    System.out.println(s);
    }
    }
    其中aa为你的共享文件夹名。
    如我的文件放在c:\\aa文件夹下。
    文件名为a.txt
      

  3.   

    测试程序:File file = new File("\\\\192.168.0.231\\C$\\1.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
    String sLine = null;
    while ((sLine = br.readLine()) != null) {
    System.out.println(sLine);
    }出力结果:
    1,2,3,4
    2,
    3,
    (就是我的1.txt里面的内容)测试环境:
    Win2000 Pro
    Eclipse 2.1.2 
    JDK 1.4.2_08