Import java. io. *;/* io stream details @ blog.csdn.net/ljfbest#/class Test {public static void main (String [] args) throws IOException {/* FileWriter fw = new FileWriter (new File ("a.txt "), true); // in windows, a line break is equivalent to \ r \ n, while in linux it is \ nfw. write ("ssss \ r \ n"); // do not forget to refresh the buffer area, not to write to a.txt, fr. the fw is automatically refreshed before closing. flush (); */FileReader fr = new FileReader ("a.txt"); char [] character = new char [3];/* a.txt: 1. abcde ---> abcdec (key understanding principle) 2. abc (here is a line feed, In windows, it is equivalent to two characters, so the output is as follows) e ---> abc e */while (fr. read (bytes ))! =-1) System. out. print (plaintext); // System. out. print (new String (buf, 0, num); fr. close () ;}import java. io. *;/* BufferedWriter, BufferedReader */class Test {public static void main (String [] args) throws IOException {/* FileWriter fw = new FileWriter ("a.txt ", true); BufferedWriter bf = new BufferedWriter (fw); bf. write ("ccc"); bf. newLine (); // enter a line break, which is \ r \ n in windows and \ nbf in linux. write ("aaa"); bf. flush (); bf. close (); */Bu FferedWriter bw = new BufferedWriter (new FileWriter ("B .txt"); BufferedReader br = new BufferedReader (new FileReader ("Test. java "); String line = null; while (line = br. readLine ())! = Null) {bw. write (line); bw. newLine (); bw. flush ();} bw. close (); br. close () ;}import java. io. *;/* BufferedWriter, BufferedReader */class Test {public static void main (String [] args) throws IOException {/* FileOutputStream fs = new FileOutputStream ("c.txt"); fs. write ("Hello! ". GetBytes (); // It must be converted to a byte array. // at this time, no refresh is required. flush () fs. close (); */FileInputStream fi = new FileInputStream ("c.txt");/* int ch; while (ch = fi. read ())! =-1) System. out. println (char) ch); */byte [] by = new byte [1024]; int len; while (len = fi. read ())! =-1) System. out. println (new String (by, 0, len); fi. close () ;}import java. io. *; import java. util. *; class Test {public static void main (String [] args) throws IOException {/* // conversion stream: streams byte streams and then uses the buffer's readLine () inputStream in = System. in; InputStreamReader is = new InputStreamReader (in); // converts the stream BufferedReader bf = new BufferedReader (is); String line = null; while (line = bf. readLine ())! = Null) System. out. println (line); * // PrinterWriter PrinterStreamBufferedReader bf = new BufferedReader (new InputStreamReader (System. in); // in this case, you do not need to use BufferedWriter to use PrintWriter instead. If true, the println, printf, or format method refreshes the output buffer PrintWriter out = new PrintWriter (System. out, true); // This is written to the console. Refresh only applies to streaming. // PrintWriter out = new PrintWriter (new BufferedWriter (new FileWriter ("a.txt "))); // The String line = null can be automatically refreshed only when it is converted to a stream. while (( Line = bf. readLine ())! = Null) out. println (line); out. close (); bf. close (); * // * DataInputStream in = new DataInputStream (System. in); int n = in. readInt (); System. out. println (n); in. close (); // Note: DataInputStream and DataOutputStream must appear in pairs * // * BufferedReader bf = new BufferedReader (new InputStreamReader (System. in); String s = bf. readLine (); byte [] B = s. getBytes ("GBK"); // The default String s1 = new String (B, "GBK") when encoding is omitted; // The System default System when decoding is omitted. out. println (s1); // System. out. println (Arrays. toString (B); */BufferedInputStream bf = new BufferedInputStream (System. in); byte [] B = new byte [10]; bf. read (B); String s = new String (B); System. out. println (s );}}