Okay following problem:
Some people on here finally thought me how to create files but now I got a small problem. I have to create very many files and I don't to copy and paste the code over and over so I wanted to know if there is a way of changing the file name after each time it has been created.
Here is the code that creates my files:
Its okay that the files always have the same writing in them but I need to figure out how to change the "Filename.txt" part after it has been created otherwise it would always overwrite itself instead of making new files. Is that possible? Can somebody tell me how?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | BufferedWriter file = null ; try { file = new BufferedWriter( new FileWriter( "Filename.txt" )); file.write( "Here is where the text would be" ); file.close(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { try { file.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } |