JAVA enables you to write any file on your secondary memory (disk drives ). Here is a sample code snippet that shows you how to write a text file in java

import java.io.BufferedWriter;

import java.io.FileWriter;

public class WriteFile 

{

public  static void main (String args[])
{
try{
// Create file 
FileWriter fs = new FileWriter("C:\HelloFile.txt");
BufferedWriter out = new BufferedWriter(fs);
out.write("Hello World");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}