-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJukebox.java
More file actions
38 lines (31 loc) · 769 Bytes
/
Jukebox.java
File metadata and controls
38 lines (31 loc) · 769 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
package com.jukebox;
import java.io.*;
import java.util.*;
public class Jukebox {
ArrayList<String> songList = new ArrayList<String>();
public static void main(String[] args) {
new Jukebox().go();
}
public void go() {
getSongs();
System.out.println(this.songList);
Collections.sort(this.songList);
System.out.println(this.songList);
}
void getSongs() {
try {
File file = new File("c:\\SongList.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = null;
while ((line = reader.readLine()) != null) {
addSong(line);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
void addSong(String lineToParse) {
String[] tokens = lineToParse.split("/");
this.songList.add(tokens[0]);
}
}