IO流

 1 import java.io.*;
 2 
 3 public class IO {
 4 
 5     public static void main(String[] args) throws IOException{
 6         String str="12345abcde@#%&*软件工程";
 7         File file=new File("d:\tset.txt");
 8         file.createNewFile();
 9         FileInputStream fr=new FileInputStream(file);
10         FileOutputStream fw=new FileOutputStream(file);
11         byte[]bw=str.getBytes();
12         fw.write(bw);
13         byte[]br=str.getBytes();
14         fr.read(br);
15         String str$=new String(br);
16         System.out.println(str$);
17         fr.close();
18         fw.close();
19     }
20 
21 }

搞清楚FileInputStream、FileOutputStream和FileReader、FileWriter用法上的区别,输入输出就显得不是那么难了。

原文地址:https://www.cnblogs.com/wjs0403/p/11132911.html