private static byte[] readBytesFromFileInputStream(FileInputStream fis) throws IOException { FileChannel channel = fis.getChannel(); int fileSize = (int) channel.size(); ByteBuffer byteBuffer = ByteBuffer.allocate(fileSize); channel.read(byteBuffer); ((Buffer) byteBuffer).flip(); //source byteBuffer.flip(); byte[] bytes = byteBuffer.array(); ((Buffer) byteBuffer).clear(); //source byteBuffer.clear(); channel.close(); fis.close(); return bytes; }
hanlp.corpus.ioIOUtil.readBytesFromFileInputStream() 定位错误
借鉴: