我的线程将从 jar 文件中读取类数据,另一个线程将修改或删除 jar 文件。订单是先读再删除,但是没用,读完好像不能释放资源,怎么联系?
InputStream is = null;
BufferedInputStream bis = null;
ByteArrayOutputStream baos = null;
try {
URL res = new URL(**file**);
is = res.openStream();
bis = new BufferedInputStream(is);
baos = new ByteArrayOutputStream();
byte[] bytes = new byte[1024 * 10];
int readBytes;
while ((readBytes = bis.read(bytes)) != -1) {
baos.write(bytes, 0, readBytes);
}
byte[] b = baos.toByteArray();
baos.close();
bis.close();
is.close();
return b;
} catch (Exception ex) {
throw ex;
}
参数“file”是这样的字符串“jar:file:///C:/Users/HJ16748/Desktop/test.jar!/com/services/plugin/test/Test.class”