{
ByteArrayOutputStream barray = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(barray);
- write(classname, out, true);
- out.close();
+ try {
+ write(classname, out, true);
+ }
+ finally {
+ out.close();
+ }
+
return barray.toByteArray();
}
directory + classname.replace('.', '/') + ".class");
int size = con.getContentLength();
InputStream s = con.getInputStream();
- if (size <= 0)
- b = ClassPoolTail.readStream(s);
- else {
- b = new byte[size];
- int len = 0;
- do {
- int n = s.read(b, len, size - len);
- if (n < 0) {
- s.close();
- throw new IOException("the stream was closed: "
- + classname);
- }
- len += n;
- } while (len < size);
+ try {
+ if (size <= 0)
+ b = ClassPoolTail.readStream(s);
+ else {
+ b = new byte[size];
+ int len = 0;
+ do {
+ int n = s.read(b, len, size - len);
+ if (n < 0)
+ throw new IOException("the stream was closed: "
+ + classname);
+
+ len += n;
+ } while (len < size);
+ }
+ }
+ finally {
+ s.close();
}
- s.close();
return b;
}