mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Attempting to fix some possible memory leaks. Son't know if I'm actually
helping anything though.
This commit is contained in:
parent
4e6086e8ed
commit
2b6b7b899e
@ -48,6 +48,7 @@ public class SpoutStuff {
|
|||||||
* @param theFilePath The name of the file path
|
* @param theFilePath The name of the file path
|
||||||
*/
|
*/
|
||||||
private static void writeFile(String theFileName, String theFilePath) {
|
private static void writeFile(String theFileName, String theFilePath) {
|
||||||
|
InputStream is = null;
|
||||||
OutputStream os = null;
|
OutputStream os = null;
|
||||||
JarFile jar = null;
|
JarFile jar = null;
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ public class SpoutStuff {
|
|||||||
|
|
||||||
jar = new JarFile(mcMMO.mcmmo);
|
jar = new JarFile(mcMMO.mcmmo);
|
||||||
JarEntry entry = jar.getJarEntry("resources/" + theFileName);
|
JarEntry entry = jar.getJarEntry("resources/" + theFileName);
|
||||||
InputStream is = jar.getInputStream(entry);
|
is = jar.getInputStream(entry);
|
||||||
|
|
||||||
byte[] buf = new byte[2048];
|
byte[] buf = new byte[2048];
|
||||||
int nbRead;
|
int nbRead;
|
||||||
@ -66,6 +67,8 @@ public class SpoutStuff {
|
|||||||
while ((nbRead = is.read(buf)) != -1) {
|
while ((nbRead = is.read(buf)) != -1) {
|
||||||
os.write(buf, 0, nbRead);
|
os.write(buf, 0, nbRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.flush();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e) {
|
catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -74,9 +77,16 @@ public class SpoutStuff {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
if (is != null) {
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
try {
|
try {
|
||||||
os.flush();
|
|
||||||
os.close();
|
os.close();
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
|
@ -155,7 +155,7 @@ public class Database {
|
|||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
if(!checkConnected()) return;
|
if(!checkConnected()) return;
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user