我是这类Java应用程序的新手,正在寻找一些示例代码,介绍如何使用SSH连接到远程服务器,执行命令,并使用Java作为编程语言获取输出.
我得到java.lang.NullPointerException的 while ((len = in.read(buf , 0 , buf.length)) >= 0)在下面的方法:
public void copy(String src, File dst) throws IOException {
InputStream in = getClass().getResourceAsStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[1012];
int len;
while ((len = in.read(buf , 0 , buf.length)) >= 0) {
out.write(buf, 0, len);
buf = null;
}
in.close();
out.close();
}
Run Code Online (Sandbox Code Playgroud)
我没有得到它.如果我得到解决方案,我会很感激.谢谢你提前.......