未找到Java网络路径错误

时间:2015-07-10 05:49:21

标签: java networking

我有这个代码。我在局域网中的一台机器上运行代码,并尝试在同一局域网中的其他机器上写入文件。我可以通过以下方式做到这一点吗?我得到例外:FileNotFound 包jcsp1;

import java.io.*;

public class test {

    public static void main(String a[]) {
        try {
            InputStream in = new FileInputStream(new File("D:\\cmds.txt"));
            OutputStream out = new FileOutputStream(new File("\\\\192.168.1.223\\D:\\test.txt"));

            // Transfer bytes from in to out
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
            in.close();
            out.close();
        }
        catch (Exception e) {
            System.out.println("error" + e);
        }
    }
}

0 个答案:

没有答案
相关问题