import java.io.FileWriter;
import java.io.IOException;
public class AutoCreateText {
public static void main(String[] args) {
String text = "This is a sample text that is auto-generated.";
String filePath = "output.txt";
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
writer.write(text);
System.out.println("Text has been written to " + filePath);
} catch (IOException e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment