Read From Console and Write to File

// IO Streams
// File handling
// Write to file
 
import java.io.*;
 
class FileWrite
{
     public static void main(String as[]) throws IOException
     {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
          FileWriter fw = new FileWriter(“F5.txt”);
         
          while(true)
          {
              String str = br.readLine().trim();
              if(str.equalsIgnoreCase(“stop”))
                   break;
              fw.write(str+”\n”);
          }
          fw.close();   
     }
}