summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-10-27 00:08:48 +0200
committersnowleo <schneeleo@gmail.com>2011-10-27 00:08:48 +0200
commit8200fc2a987d97df01e5479ee42b174f8ab20742 (patch)
tree4f109d45fed77392c3864043fddc9733d4ef9e3a
parent4b6fc99a62b0d2da88bd3abb0aafc07460671e43 (diff)
downloadEssentials-8200fc2a987d97df01e5479ee42b174f8ab20742.tar
Essentials-8200fc2a987d97df01e5479ee42b174f8ab20742.tar.gz
Essentials-8200fc2a987d97df01e5479ee42b174f8ab20742.tar.lz
Essentials-8200fc2a987d97df01e5479ee42b174f8ab20742.tar.xz
Essentials-8200fc2a987d97df01e5479ee42b174f8ab20742.zip
Close file input on exception
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java40
1 files changed, 24 insertions, 16 deletions
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java
index 58bbb25b0..824383285 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/chat/AbstractFileCommand.java
@@ -33,29 +33,37 @@ public abstract class AbstractFileCommand implements Command
throw new IOException("Server log not found.");
}
final FileInputStream fis = new FileInputStream(logFile);
- if (logFile.length() > 1000000)
+ try
{
- fis.skip(logFile.length() - 1000000);
+ if (logFile.length() > 1000000)
+ {
+ fis.skip(logFile.length() - 1000000);
+ }
+ return new BufferedReader(new InputStreamReader(fis));
+ }
+ catch (IOException ex)
+ {
+ fis.close();
+ throw ex;
}
- return new BufferedReader(new InputStreamReader(fis));
}
-
+
protected BufferedReader getPluginConfig(final String pluginName, final String fileName) throws IOException
{
final File configFolder = new File(plugin.getDataFolder().getAbsoluteFile().getParentFile(), pluginName);
- if (!configFolder.exists())
- {
- throw new IOException(pluginName+" plugin folder not found.");
- }
- final File configFile = new File(configFolder, fileName);
- if (!configFile.exists())
- {
- throw new IOException(pluginName+" plugin file "+fileName+" not found.");
- }
- return new BufferedReader(new InputStreamReader(new FileInputStream(configFile), UTF8));
-
+ if (!configFolder.exists())
+ {
+ throw new IOException(pluginName + " plugin folder not found.");
+ }
+ final File configFile = new File(configFolder, fileName);
+ if (!configFile.exists())
+ {
+ throw new IOException(pluginName + " plugin file " + fileName + " not found.");
+ }
+ return new BufferedReader(new InputStreamReader(new FileInputStream(configFile), UTF8));
+
}
-
+
protected String uploadToPastie(final StringBuilder input) throws IOException
{
if (input.length() > 15000)