Q:

Java - Write the Text File

0

This Program is used to write any text to the File.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// 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...");   

             }

     }

 }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now