by Dinesh Thakur Category: Stream

The constructor of FileOutputStream class is overload, when we pass Boolean argument (true) in the constructor of FileOutputStream, then the new text append in the file.

FileOutputStream file = new FileOutputStream ("Hello.txt", true);

Here is the Java Example for Append Text to File:


class AppendTexttoFile
          public static void main(String args[])throws IOException
                   BufferedReader br=new BufferedReader(new InputStreamReader(;
                   FileOutputStream file = new FileOutputStream("Hello.txt",true);
                   System.out.println("Enter the text and Type 'y' to Terminate");
                   char ch;
                    catch(IOException e) {}

Append Text to File Java Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles