I want to create a file in windows with java program with the help of the attached program but whenever I do that the extension name appears in the file name.I want extension of this file to be txt on windows.How do I rectify this problem.
import java.io.*;
public class Program {
public static void main(String[] args) {
String text = "Hello world";
try {
File file = new File("example.txt");
BufferedWriter output = new BufferedWriter(new FileWriter(file));
output.write(text);
output.close();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}