,我在下面的方法獲得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