【发布时间】:2009-12-02 08:57:09
【问题描述】:
我通过以下方法在while ((len = in.read(buf , 0 , buf.length)) >= 0) 获得java.lang.NullPointerException:
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();
}
我没有得到 coz。如果我得到解决方案,我将不胜感激。在此先感谢.......
【问题讨论】:
-
如果你将'buf'设置为null...它将为null。