// 编写一个程序,在E盘下创建一个abc.txt的文本文档,通过输出流在文档内添加数据,然后在把abc.txt复制到F盘下

时间:2022-09-14 23:21:44
package day1031;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


public class Zuoye {
String s = "输入的内容";


public FileOutputStream fos;
public FileInputStream fis;


public Zuoye(String name) throws FileNotFoundException {
fos = new FileOutputStream(name);
fis = new FileInputStream(name);
}


public void FileOutput() throws IOException {
fos.write(s.getBytes());
fos.close();
}


public void FileInput() throws IOException {


byte[] b = new byte[1024];
int length = fis.read(b);
fis.read(b, 0, length);
fis.close();


}


public static void main(String[] args) throws IOException {



Zuoye z1 = new Zuoye("e:\\abc.txt");
z1.FileOutput();
z1.FileInput();
Zuoye z2 = new Zuoye("f:\\abc.txt");
z2.FileOutput();

}


}