Write a program to write the text into the file, named as file.txt using java ? Filewriter Class
The following code will help you to write some text into the file using FileWriter Class.
Table of Contents
Java Program Code
/*;==========================================
; Title: Write text into file using java ? Use Java Filewriter Class.
; Author: codenaive littleboy8506@
; Date: 13 Dec 2021
;==========================================*/
import java.io.*;
class First
{
public static void main(String[] arg)
{
try{
FileWriter fw=new FileWriter("file.txt");
fw.write("Hello FIle ");
fw.close();
System.out.println("Success....");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Output
C:\codenaive>java First
Success....
Leave a Reply