OSDN Git Service

add channel close(I don't know it's necessary).
authorKazuhiko Kobayashi <chototsu_moushinp@yahoo.co.jp>
Tue, 12 Jun 2012 22:31:54 +0000 (07:31 +0900)
committerKazuhiko Kobayashi <chototsu_moushinp@yahoo.co.jp>
Tue, 12 Jun 2012 22:31:54 +0000 (07:31 +0900)
src/projectkyoto/mmd/file/util2/BufferUtil.java

index fbc711d..a253b7a 100644 (file)
@@ -11,6 +11,7 @@ import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
 import java.nio.channels.FileChannel.MapMode;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -41,8 +42,10 @@ public class BufferUtil {
             RandomAccessFile os = new RandomAccessFile(tmpFile, "rw");
             os.seek(size);
             os.write(0);
-            MappedByteBuffer  bb = os.getChannel().map(MapMode.READ_WRITE, 0, size);
+            FileChannel ch = os.getChannel();
+            MappedByteBuffer  bb = ch.map(MapMode.READ_WRITE, 0, size);
             os.close();
+            ch.close();
             tmpFile.delete();
             bb.order(ByteOrder.nativeOrder());
             return bb;