java FileInputStream的相对路径 是相对于src目录的
public void bufferTest(){
try (FileChannel channel = new FileInputStream("src/main/resources/data.txt").getChannel()){
ByteBuffer byteBuffer = ByteBuffer.allocate(16);
int count = channel.read(byteBuffer);
log.info("读的字节数:"+count);
byteBuffer.flip();
while (byteBuffer.hasRemaining()){
byte b = byteBuffer.get();
log.info("内容"+(char)b);
}
} catch (Exception e) {
e.printStackTrace();
}
}
标签:java,log,byteBuffer,相对路径,ByteBuffer,FileInputStream From: https://www.cnblogs.com/youran-he/p/16710118.html