File Write
# Java Example - File Writing
[ Java Example](#)
The following example demonstrates using the write() method to write content to a file:
## Example
/* author by Main.java */import java.io.*; public class Main{public static void main(String[]args){try{BufferedWriter out = new BufferedWriter(new FileWriter(".txt")); out.write(""); out.close(); System.out.println("File created successfully!"); }catch(IOException e){}}}
The output of the above code is:
File created successfully!
After successful creation, a file named .txt will be generated in the current directory, and the string "" will be written into that file.
[ Java Example](#)
YouTip