Try to fix interrupt problem.

This commit is contained in:
snowleo 2012-08-05 19:41:06 +02:00
parent 7beab59c1a
commit c7b90f61f7

View File

@ -5,6 +5,7 @@ import com.google.common.io.Files;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
@ -117,7 +118,30 @@ public class EssentialsConf extends YamlConfiguration
{
final FileChannel channel = inputStream.getChannel();
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
channel.read(buffer);
boolean retry;
do
{
try
{
int BUFFERSIZE = 1024;
long left = configFile.length() % BUFFERSIZE;
for (long i = 0; i < configFile.length() - left; i += BUFFERSIZE)
{
channel.read(buffer, BUFFERSIZE);
}
if (left > 0)
{
channel.read(buffer, left);
}
retry = false;
}
catch (ClosedByInterruptException ex)
{
buffer.rewind();
retry = true;
}
}
while (retry);
buffer.rewind();
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
CharsetDecoder decoder = UTF8.newDecoder();