public static void testIOStream() throws IOException { InputStream inputStream = new FileInputStream("C:\\test.txt"); OutputStream outputStream = new FileOutputStream("E:\\test.txt"); int x; while ((x = inputStream.read()) != -1) { outputStream.write(x); } inputStream.close(); outputStream.close(); System.out.println("文件复制成功!"); }