-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusicStuff.java
49 lines (44 loc) · 932 Bytes
/
musicStuff.java
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
42
43
44
45
46
47
48
49
import java.lang.*;
import java.io.*;
import java.util.*;
public class musicStuff
{
File[] list;
ArrayList<String> songlist = new ArrayList<String>();
int numSongs = 0;
public musicStuff(File[] f)
{
list = f;
sort();
}
public void sort()
{
for(int i = 0; i < list.length; i++)
{
File[] temp = list[i].listFiles();
try{
for(int j = 0 ; j < temp.length; j++)
{
String s = temp[j].getName();
String ar[] = s.split("-");
if((ar[ar.length-1].endsWith(".mp3")||ar[ar.length-1].endsWith(".wma")))
{
songlist.add(ar[ar.length-1].trim());
numSongs++;
}
}}
catch(NullPointerException e){}
}
}
public void songList()
{
System.out.println("Songs List: \n");
Collections.sort(songlist);
for(String s: songlist)
System.out.println(s);
}
public String numSongs()
{
return "" + numSongs + " Songs.";
}
}