}
} else {
OutputStream out = new FileOutputStream(f2);
- Writer w = new OutputStreamWriter(out);
- w.write(toString(val));
- w.flush();
- out.close();
+ try {
+ Writer w = new OutputStreamWriter(out);
+ w.write(toString(val));
+ w.flush();
+ } finally {
+ out.close();
+ }
}
} catch (IOException ioe) {
throw new JSExn.IO(ioe);
}
public Object get(Object key0) throws JSExn {
+ FileInputStream fis = null;
try {
if (key0 == null) return null;
String key = toString(key0);
if (f2.isDirectory()) return new Directory(f2);
char[] chars = new char[((int)f2.length()) * 2];
int numchars = 0;
- Reader r = new InputStreamReader(new FileInputStream(f2));
+ fis = new FileInputStream(f2);
+ Reader r = new InputStreamReader(fis);
while(true) {
int numread = r.read(chars, numchars, chars.length - numchars);
if (numread == -1) return new String(chars, 0, numchars);
}
} catch (IOException ioe) {
throw new JSExn.IO(ioe);
+ } finally {
+ try {
+ if (fis != null) fis.close();
+ } catch (IOException ioe) {
+ throw new JSExn.IO(ioe);
+ }
}
}