使用InputStream和OutputStream复制文本文件
import java.io.FileInputStream; /**来自 时 代 J a v a**/ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class OuputStreamTest { public static void main(String[] args) throws IOException{ InputStream inputStream = null; OutputStream outputStream = null; try{ inputStream = new FileInputStream("C:/input.txt"); outputStream = new FileOutputStream("C:/output.txt"); byte[] bytes = new byte[1024]; int index; while((index = inputStream.read(bytes)) != -1){ System.out.println("index ="+index); outputStream.write(bytes, 0, index); /** from 时 代 J a v a 公 众 号 - nowjava.com**/ } }