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
Code: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."); } }
Results 1 to 3 of 3
Thread: [Java]Simple Text File Creator
- 01 Aug. 2010 02:24pm #1
[Java]Simple Text File Creator
LG's Dyke. Enough. Said.
- 01 Aug. 2010 08:07pm #2
Great source code darling
Im greatly proud you have moved onto a good language like javaShh, I'm watching My little pony.
- 01 Aug. 2010 08:10pm #3
Thanks Bman, I appreciate it.
LG's Dyke. Enough. Said.