package InOut;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class InOutDemo {
public static void main(String[] args) throws IOException {
FileInputStream fileInputStream = new FileInputStream("");
FileOutputStream fileOutputStream = new FileOutputStream("");
// 定义一个集合用来接收数据
// 定义这个集合的长度,集合长度为1024的整数倍
byte[] b = new byte[1024 * 8];
int len;
// 可以一次性读取1024整数倍的数据
while ((len = fileInputStream.read(b)) != -1) {
// len代表最终写入的字节个数
fileOutputStream.write(b, 0, len);
}
fileInputStream.close();
fileOutputStream.close();
}
}
【笔记】文件传输提高效率
最新推荐文章于 2024-04-30 17:28:01 发布