Close resources

This commit is contained in:
str4d
2013-11-25 23:14:09 +00:00
parent 615ba94559
commit e77409e57a
7 changed files with 40 additions and 36 deletions

View File

@ -214,12 +214,12 @@ public class SAMBridge implements Runnable, ClientApp {
private void loadKeys() {
synchronized (nameToPrivKeys) {
nameToPrivKeys.clear();
FileInputStream in = null;
BufferedReader br = null;
try {
in = new FileInputStream(persistFilename);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
br = new BufferedReader(new InputStreamReader(
new FileInputStream(persistFilename)));
String line = null;
while ( (line = reader.readLine()) != null) {
while ( (line = br.readLine()) != null) {
int eq = line.indexOf('=');
String name = line.substring(0, eq);
String privKeys = line.substring(eq+1);
@ -230,7 +230,7 @@ public class SAMBridge implements Runnable, ClientApp {
} catch (IOException ioe) {
_log.error("Unable to read the keys from " + persistFilename, ioe);
} finally {
if (in != null) try { in.close(); } catch (IOException ioe) {}
if (br != null) try { br.close(); } catch (IOException ioe) {}
}
}
}