If I have a standard txt file and I'm reading it in using either FileInputStream or FileReader, how can I convert that into a .py file using Java?
Asked
Active
Viewed 1,706 times
-1
-
This makes no sense. How do you turn arbitrary text into Python source code? – Stephen C Oct 26 '14 at 06:14
-
Do you have to read it in via a stream or reader? – Alvin Bunk Oct 26 '14 at 06:14
-
If you are simply asking how to copy a file with a different name in Java, that has been asked and answered many time before. – Stephen C Oct 26 '14 at 06:15
-
Ditto for renaming a file. – Stephen C Oct 26 '14 at 06:43
-
Probable duplicate of this: http://stackoverflow.com/questions/106770/standard-concise-way-to-copy-a-file-in-java – Stephen C Oct 26 '14 at 06:44
-
Wow... looking back on this after these years, I have **absolutely** no idea what I was trying to do here... – Broots Waymb Jun 01 '18 at 18:11
1 Answers
1
You don't have to read the file. All you have to do is change the file name:
File txtFile = new File("somefile.txt");
File pyFile = new File("somefile.py");
txtFile.renameTo(pyFile);

Code-Apprentice
- 81,660
- 23
- 145
- 268