-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintingMusicData.java
More file actions
52 lines (43 loc) · 1.38 KB
/
PrintingMusicData.java
File metadata and controls
52 lines (43 loc) · 1.38 KB
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
50
import java.io.BufferedReader;
import java.io.FileReader;
public class PrintingMusicData extends Music {
private static BufferedReader file;
public static String filename = "/tmp/spotifyMusicData.csv"; // Add your .csv file path
static String formattedDate = "";
static String formattedArtists = "";
public static void openFile() {
try {
file = new BufferedReader(new FileReader(filename));
} catch (Exception e) {
System.out.println("File not found");
}
}
public static void readFile(boolean firstLine) {
String fileLine;
try {
while ((fileLine = file.readLine()) != null && !firstLine) {
FormattingMusicArray.readFileLine(fileLine, true);
}
} catch (Exception e) {
System.out.printf("Error while trying to read file: %s\n", e);
}
}
public static void closeFile() {
try {
file.close();
} catch (Exception e) {
System.out.printf("Error while closing the file: %s", e);
}
}
public static void main(String[] args) {
MyIO.setCharset("UTF-8");
try {
openFile();
readFile(true);
readFile(false);
closeFile();
} catch (Exception e) {
System.out.printf("An error occurred: %s", e);
}
}
}