The Java's IO operation is based on streams, and it is generally necessary to improve read and write efficiency.
Simple sample programs are as follows:
/ **
* Read the contents of the 1.txt, write into 2.TXT
*
* /
Import java.io. *;
Public class readwritefile {public static void main (string [] args) {Try {file read = new file ("c: //1.txt"); file write = new file ("c: //2.txt") ; BufferedReader br = new BufferedReader (new FileReader (read)); BufferedWriter bw = new BufferedWriter (new FileWriter (write)); String temp = null; temp = br.readLine (); while (! temp = null) {// Write the file BW.WRITE (Temp "/ R / N"); // only apply the Windows system // Continue reading file temp = br.readline ();} bw.close (); br.close ();} catch (FilenotFoundException E) {// File Didn't find System.out.Println (E);} catch (ioException e) {system.out.println (e);}}}