Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java认证后如何在网络中打开共享文件夹_Java_Authentication_Shared Directory - Fatal编程技术网

java认证后如何在网络中打开共享文件夹

java认证后如何在网络中打开共享文件夹,java,authentication,shared-directory,Java,Authentication,Shared Directory,我需要使用Java代码执行以下操作: 1.win+R(跑步) 2.粘贴共享文件夹位置,如:“\10.10.10.0\aaa\bbb” 3.需要在身份验证窗口中填写用户id和pwd 我写了以下代码 public void accessSharedPath(String path) { Authenticator.setDefault(new SharedPathAuthenticator()); try { new ProcessBuil

我需要使用Java代码执行以下操作: 1.win+R(跑步) 2.粘贴共享文件夹位置,如:“\10.10.10.0\aaa\bbb” 3.需要在身份验证窗口中填写用户id和pwd

我写了以下代码

public void accessSharedPath(String path) {

        Authenticator.setDefault(new SharedPathAuthenticator());

        try {
            new ProcessBuilder("explorer.exe", path1).start();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

class SharedPathAuthenticator extends Authenticator {
    private String userName = "xxxx";
    private char[] password = { 'x', 'x', 'x', 'x', 'x', 'x', 'x' };

    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(userName, password);

    }
}
现在的问题是,如果在我的机器中,身份验证之前已经完成,那么它可以正常工作(即使没有身份验证程序),但是当我删除保存的密码并运行它时,它会打开我的文档文件夹