博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
利用字节流拷贝文件
阅读量:676 次
发布时间:2019-03-16

本文共 650 字,大约阅读时间需要 2 分钟。

public class FileCopy {
public static void main(String[] args) throws IOException {
// 输入流 FileInputStream fileInputStream = new FileInputStream(new File("D:\\abc.txt")); // 输出流 FileOutputStream fileOutputStream = new FileOutputStream("D:\\abc(字节方式).txt"); // 缓冲区(每次读10字节) byte[] bytes = new byte[10]; // 写到文件中 int length; while((length = fileInputStream.read(bytes)) != -1){
System.out.println(new String(bytes)); fileOutputStream.write(bytes, 0, length); } // 关闭流 fileOutputStream.close(); fileInputStream.close(); }}

转载地址:http://abrqz.baihongyu.com/

你可能感兴趣的文章