,我在下面的方法获得java.lang.NullPointerException
在while ((len = in.read(buf , 0 , buf.length)) >= 0)
:的Java空指针异常
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.I应该心存感激,如果我得到的solution.thanks提前.... ...
如果您将'buf'设置为null ...则它将为空。 – 2009-12-02 09:02:47