gpt4 book ai didi

java - 修改FileInputStream(文件的某些部分)

转载 作者:太空宇宙 更新时间:2023-11-04 06:18:23 24 4
gpt4 key购买 nike

如何获取现有文件的 FileInputStream ,该文件不会遍历整个文件,而是遍历文件的指定部分(从字节 m 到字节 n)?

编辑:我需要 FileInputStream 将其提交到 org.apache.commons.net.ftp.FTPClient.storeFile .

最佳答案

File file = ...
FileInputStream fis = new FileInputStream(file);
long m = ....
fis.getChannel().position(m);
int n = ...
byte[] buffer = new byte[n];
fis.read(buffer);

关于java - 修改FileInputStream(文件的某些部分),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27770533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com