mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-13 08:28:02 +02:00
Close file input on exception
This commit is contained in:
parent
4b6fc99a62
commit
8200fc2a98
@ -33,24 +33,32 @@ public abstract class AbstractFileCommand implements Command
|
|||||||
throw new IOException("Server log not found.");
|
throw new IOException("Server log not found.");
|
||||||
}
|
}
|
||||||
final FileInputStream fis = new FileInputStream(logFile);
|
final FileInputStream fis = new FileInputStream(logFile);
|
||||||
|
try
|
||||||
|
{
|
||||||
if (logFile.length() > 1000000)
|
if (logFile.length() > 1000000)
|
||||||
{
|
{
|
||||||
fis.skip(logFile.length() - 1000000);
|
fis.skip(logFile.length() - 1000000);
|
||||||
}
|
}
|
||||||
return new BufferedReader(new InputStreamReader(fis));
|
return new BufferedReader(new InputStreamReader(fis));
|
||||||
}
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
fis.close();
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected BufferedReader getPluginConfig(final String pluginName, final String fileName) throws IOException
|
protected BufferedReader getPluginConfig(final String pluginName, final String fileName) throws IOException
|
||||||
{
|
{
|
||||||
final File configFolder = new File(plugin.getDataFolder().getAbsoluteFile().getParentFile(), pluginName);
|
final File configFolder = new File(plugin.getDataFolder().getAbsoluteFile().getParentFile(), pluginName);
|
||||||
if (!configFolder.exists())
|
if (!configFolder.exists())
|
||||||
{
|
{
|
||||||
throw new IOException(pluginName+" plugin folder not found.");
|
throw new IOException(pluginName + " plugin folder not found.");
|
||||||
}
|
}
|
||||||
final File configFile = new File(configFolder, fileName);
|
final File configFile = new File(configFolder, fileName);
|
||||||
if (!configFile.exists())
|
if (!configFile.exists())
|
||||||
{
|
{
|
||||||
throw new IOException(pluginName+" plugin file "+fileName+" not found.");
|
throw new IOException(pluginName + " plugin file " + fileName + " not found.");
|
||||||
}
|
}
|
||||||
return new BufferedReader(new InputStreamReader(new FileInputStream(configFile), UTF8));
|
return new BufferedReader(new InputStreamReader(new FileInputStream(configFile), UTF8));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user