最简单的输入输出流文件复制(JAVA) public class Dmo02 { public static void main(String[] args) { File f = new File("d:/JAVA/txt1.txt"); File f2 = new File("d:/JAVA/txt2.txt"); try { FileInputStream fileInputStream = new FileInputStream(f); FileOutputStream fileOutputStream = new FileOutputStream(f2); byte[] b = new byte[(int) f.length()]; fileInputStream.read(b); fileOutputStream.write(b); //每次使用完流,都应该进行关闭 fileInputStream.close(); fileOutputStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }