java认证后如何在网络中打开共享文件夹
我需要使用Java代码执行以下操作: 1.win+R(跑步) 2.粘贴共享文件夹位置,如:“\10.10.10.0\aaa\bbb” 3.需要在身份验证窗口中填写用户id和pwd 我写了以下代码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
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);
}
}
现在的问题是,如果在我的机器中,身份验证之前已经完成,那么它可以正常工作(即使没有身份验证程序),但是当我删除保存的密码并运行它时,它会打开我的文档文件夹