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(); } }