From d9a00cb6d478f0cf2f846d5d53003296fed94139 Mon Sep 17 00:00:00 2001 From: pj3q7x5mz <1732875197@qq.com> Date: Thu, 17 Nov 2022 11:22:45 +0800 Subject: [PATCH] ADD file via upload --- ...节数据输入输出之综合练习.txt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Java输入输出之字节数据输入输出之综合练习.txt diff --git a/Java输入输出之字节数据输入输出之综合练习.txt b/Java输入输出之字节数据输入输出之综合练习.txt new file mode 100644 index 0000000..9807a70 --- /dev/null +++ b/Java输入输出之字节数据输入输出之综合练习.txt @@ -0,0 +1,24 @@ +import java.io.*; +import java.util.Scanner; + +public class FileTest { + public static void main(String[] args) throws IOException { + // 请在Begin-End间编写完整代码 + /********** Begin **********/ + // 使用字节输出流和输入流,把给定文件里的内容复制到另一个给定文件中 + Scanner input = new Scanner(System.in); + String path1 = input.next(); + String path2 = input.next(); + FileInputStream fis = new FileInputStream(path1); + FileOutputStream fos = new FileOutputStream(path2); + int a = 0; + while((a=fis.read())!=-1){ + fos.write(a); + } + fis.close(); + fos.close(); + + + /********** End **********/ + } +} \ No newline at end of file