简体   繁体   English

使用Java连接到Lan的其他PC中创建文件

[英]Creating File in other pc Connected to Lan using java

I am trying to Create a txt file using java in other pc and i am trying to doing code is. 我正在尝试在其他PC中使用Java创建txt文件,而我正在尝试执行代码。

try {
            File f = new File("sftp://ip/home/username/krish.txt");

            boolean check = f.createNewFile();
            if (check) {
                System.out.println("File Created!!!");
                return true;
            }
            else{
                System.out.println("File not Created!!!");
                return false;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

what i am getting error is : 我得到的错误是:

java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:959)

can any body suggest solution? 有人可以建议解决方案吗?

To manage file that are in a remote machine you will use a network communication protocol. 要管理远程计算机中的文件,您将使用网络通信协议。 in your case you are trying to use Secure FTP , so you have to use a Java API that handle this job . 在您的情况下,您尝试使用安全FTP,因此必须使用Java API来处理此工作。 try JSch it may help you. 尝试JSch可能会对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM