forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenCSVReadEx.java
More file actions
29 lines (22 loc) · 822 Bytes
/
OpenCSVReadEx.java
File metadata and controls
29 lines (22 loc) · 822 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
package com.zetcode;
import com.opencsv.CSVReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
public class OpenCSVReadEx {
public static void main(String[] args) throws IOException {
String fileName = "src/main/resources/numbers.csv";
try (FileInputStream fis = new FileInputStream(fileName);
InputStreamReader isr = new InputStreamReader(fis,
StandardCharsets.UTF_8);
CSVReader reader = new CSVReader(isr)) {
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
for (String e : nextLine) {
System.out.format("%s ", e);
}
}
}
}
}