| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package audio.io;
- import java.io.File;
- import java.io.FileFilter;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import audio.Song;
- public class DirScanner {
-
- public static List<Song> scanDirectories(File f)
- {
- List<Song> songs = new ArrayList<Song>();
- if(!f.isDirectory())
- return songs;
-
- FileFilter dirs = new FileFilter()
- {
- public boolean accept(File e) {
- if(e.isDirectory())
- return true;
- else
- return false;
- }
- };
- FileFilter csf = new FileFilter()
- {
- public boolean accept(File e) {
- if(e.isFile() && e.getName().endsWith(".csf"))
- return true;
- else
- return false;
- }
- };
-
- for(File file : f.listFiles(dirs))
- {
- for(File file2 : file.listFiles(csf))
- {
- try {
- Song s = JSONReader.readSong(file2);
- songs.add(s);
- } catch (IOException e1) {
- e1.printStackTrace();
- }
-
- }
- }
-
- return songs;
- }
- }
|