Java

Java - Write the Text File

Java - Write the Text File
// Write the File

 

import java.io.*;

public class test9

 {

  public static void main(String arg[])

    {

      try

       {

         BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 

         String str;

         FileWriter fw = new FileWriter("abc.txt");

         BufferedWriter bw = new BufferedWriter(fw);

         System.out.println("\nEnter the Text....\n");

           do

             {

               str = br.readLine();

               bw.write(str+"\n");

               }while(!str.equals("stop"));

                bw.close();   fw.close();

           }

            catch(Exception e)

             { 

                System.out.println("Error...");   

             }

     }

 }
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.