-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileLoader.java
More file actions
41 lines (36 loc) · 971 Bytes
/
FileLoader.java
File metadata and controls
41 lines (36 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.File;
import java.util.ArrayList;
/**
* Loads all the files into an arrayList<String>, which contains all of the file
* locations in the directory ending in mp3.
*
* @author Michael Nipper
*
*/
public class FileLoader {
private ArrayList<String> fileList = new ArrayList<String>();
/**
* Loads all of filepaths in a given directory as an ArrayList of strings.
* @param dir String A directory to load.
*/
public FileLoader(String dir) {
String file;
File folder = new File(dir);
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
file = listOfFiles[i].getName();
if (file.endsWith(".mp3")) {
fileList.add(dir + "\\" + file);
}
}
}
}
/**
* Get the file list.
* @return ArrayList<String> The arraylist of filepaths.
*/
public ArrayList<String> getFileList() {
return fileList;
}
}