. 1 Package org.java; 2 . 3 Import java.io.BufferedReader; . 4 Import java.io.BufferedWriter; . 5 Import java.io.File; . 6 Import java.io.FileReader; . 7 Import java.io.FileWriter; . 8 Import Java .util.Scanner; . 9 10 . 11 public class Main16 { 12 is public static void main (String [] args) { 13 is / * 14 * using the input / output stream class, a number of characters read from the keyboard, 15 * and the character display at the same time on the screen, written to a file test.dat file. 16 * / . 17 the try { 18 is String path = "C: \\ \\ Nirobert Einteson the Users \\ Desktop File \\ \\ \\ Java"; // directory where the file . 19 File fileData = new new File (path + "Test .dat " ); 20 is FileWriter FileWriter = new new FileWriter (fileData); // character 21 is BufferedWriter, BufferedWriter = new new BufferedWriter, (FileWriter); // character requires enhanced character as a parameter 22 is Scanner Reader = new new Scanner (the System.in) ; 23 is the while (reader.hasNextLine ()) { //reader.hasNext () 24- String String = reader.nextLine (); // really do not know reader.next () exit condition of the 25 IF (string.isEmpty ()) BREAK ; // wrap exit \ the n- 26 bufferedWriter.write (string); // write a string or array of strings 27 bufferedWriter.newLine (); // write a line break 28 } 29 bufferedWriter.close (); 30 fileWriter.close (); 31 is 32 // read character 33 is the FileReader FileReader = new new the FileReader (fileData); 34 BufferedReader bufferedReader=new BufferedReader(fileReader); 35 36 String string2; 37 while((string2=bufferedReader.readLine())!=null) { 38 System.out.println(string2); 39 } 40 bufferedReader.close(); 41 fileReader.close(); 42 43 } catch (Exception e) { 44 System.out.println(e); 45 } 46 } 47 }