swe*_*ety -1 java bytearray stream
我得到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)
我没有得到它.如果我得到解决方案,我会很感激.谢谢你提前.......
Alb*_*gni 10
你设定
buf = null;
Run Code Online (Sandbox Code Playgroud)
在第一次迭代中,在第二次buf.length处抛出NullPointerException.