[Java]Simple Text File Creator
It basically makes multiple text files w/ a message. You can just put a space if you want blank text files.
Example input / output:
Number of files to create:
3
Name to give file:
test
Write to file:
hello
Done creating. Check project folder.
Created Files: (in project folder)
test0
test1
test2
(each w/ the word hello in them)
Source
Example input / output:
Number of files to create:
3
Name to give file:
test
Write to file:
hello
Done creating. Check project folder.
Created Files: (in project folder)
test0
test1
test2
(each w/ the word hello in them)
Source
import java.io.*;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int num;
String message = "";
String name = "";
InputStreamReader strinput = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(strinput);
System.out.println("Number of files to create: ");
num = input.nextInt();
System.out.println("Name to give file: ");
try{name = reader.readLine();}catch(Exception e){}
System.out.println("Write to file: ");
try{message = reader.readLine();}catch(Exception e){}
for(int x = 0; x<num; x++)
{
try
{
FileWriter fstream = new FileWriter(name + x + ".txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write(message);
out.close();
}catch (Exception e){System.err.println("Error: " + e.getMessage());}
}
System.out.println("Done creating. Check project folder.");
}
}
