Skip to main content

Posts

Showing posts with the label program

Day-to-day Programming 1: File names into a text file

How to get the names of the files in a specific directory (folder)  to a text file? Today my mother asked me to write some MP3s into a DVD. There were nearly 200 MP3 files. and she also asked me to number them and make a list of file names to print out. I was like o.O how am I going to do that? type all 200 file names into a document? I felt lazy and thought why can't I write a program that will do it for me !. so I wrote a simple program that gets file names and writes them into a text file, so I can print them out. This is the simple program I wrote. It took less than 2 minutes to write it. and saved a considerable amount of time!  ;) 1: import java.io.BufferedWriter; 2: import java.io.File; 3: import java.io.FileWriter; 4: import java.io.IOException; 5: 6: public class FilenamesToTxt { 7: public static void main(String[] args) throws IOException { 8: File folder = new File("C:/My Folder"); 9: BufferedWriter bf ...