Merge pull request #2961 from joelmoniz/closeStreams

Closing a few unclosed BufferedReaders and InputStreams
This commit is contained in:
Ben Fry
2015-04-01 17:21:16 -04:00
3 changed files with 20 additions and 3 deletions
+1
View File
@@ -84,6 +84,7 @@ public class Recent {
}
}
}
reader.close();
}
updateMenu(mainMenu);
updateMenu(toolbarMenu);
+18 -3
View File
@@ -4925,6 +4925,7 @@ public class PApplet implements PConstants {
// with the old method.
outgoing.checkAlpha();
stream.close();
// return the image
return outgoing;
@@ -5135,7 +5136,7 @@ public class PApplet implements PConstants {
}
}
}
is.close();
return outgoing;
}
@@ -6330,7 +6331,13 @@ public class PApplet implements PConstants {
*/
static public byte[] loadBytes(File file) {
InputStream is = createInput(file);
return loadBytes(is);
byte[] byteArr = loadBytes(is);
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return byteArr;
}
/**
@@ -6396,7 +6403,15 @@ public class PApplet implements PConstants {
*/
public String[] loadStrings(String filename) {
InputStream is = createInput(filename);
if (is != null) return loadStrings(is);
if (is != null) {
String[] strArr = loadStrings(is);
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return strArr;
}
System.err.println("The file \"" + filename + "\" " +
"is missing or inaccessible, make sure " +
+1
View File
@@ -232,6 +232,7 @@ public class PShapeOBJ extends PShape {
BufferedReader mreader = parent.createReader(fn);
if (mreader != null) {
parseMTL(parent, path, mreader, materials, mtlTable);
mreader.close();
}
}
} else if (parts[0].equals("g")) {