java FileInputStream的相对路径

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();
}
}


 

posted @ 2022-09-20 10:17  李悠然  阅读(1841)  评论(0编辑  收藏  举报