提交 5668210d 编写于 作者: S Serge Rider

ByteBuffer.flip usage fix (Java8 compatibility)

上级 fa213e7f
......@@ -19,6 +19,7 @@ package org.jkiss.utils;
import java.io.*;
import java.net.ServerSocket;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
......@@ -67,18 +68,22 @@ public final class IOUtils {
final ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize);
while (src.read(buffer) != -1) {
buffer.flip();
flipBuffer(buffer);
dest.write(buffer);
buffer.compact();
}
buffer.flip();
flipBuffer(buffer);
while (buffer.hasRemaining()) {
dest.write(buffer);
}
}
public static void flipBuffer(Buffer buffer) {
buffer.flip();
}
public static void copyStream(
java.io.InputStream inputStream,
java.io.OutputStream outputStream)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册