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

Popular Article