I do not know how you can run this file when in the state as is it would not compile with about 10 error messages. What about class declaration public class CreateTestTxt for example
import java.io.*;
import java.util.*;
public class CreateTestTxt
{
public static void main (String[] arg)
{
try
{
String file_name = "test.txt";
FileWriter file = new FileWriter(file_name);
BufferedWriter out = new BufferedWriter (file);
String text = "This is goint to be written to the file";
out.write(text);
out.close();
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
}
Difficult to comment on realy beginners stuff which you should know
peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902