Write Data into the File
Java Code to Write the Data into the File:
import java.io.File;
import java.io.*;
public class FileHandling
{
public static void main(String[] args)throws IOException
{
FileWriter fw=new FileWriter("c:\\guleria\\compuhelp.txt",true);
//second argument is append mode
fw.write("Welcome you in java file handling\n");
fw.write("This is second line.\n");
fw.write("This is third line\n");
fw.close();
System.out.println("Data saved to file");
}//end of main
}//end of class
Write the Data into the File using FileOutputStream class:
//DataOutputStream class is used to write data to the FileOutputStream //DataOutputStream class has no. of methods to write data to the file.