-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNunuReadRow
More file actions
37 lines (28 loc) · 930 Bytes
/
NunuReadRow
File metadata and controls
37 lines (28 loc) · 930 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
import java.io.File;import java.io.FileNotFoundException;
import java.io.IOException;import java.util.ArrayList;
import java.util.List;import java.util.Scanner;
public class tc {
public static void main(String[] args)
throws FileNotFoundException, IOException {
Scanner sc = new Scanner(new File("C:\\dok.csv"));
while (sc.hasNextLine())
{
readRow( sc.nextLine() );
}
sc.close();
}//m
static List<String> readRow(String line) {
List<String> row = new ArrayList<String>();
try (Scanner sc2 = new Scanner(line)) {
sc2.useDelimiter(",");
while (sc2.hasNext()) {
row.add(sc2.next());
}
System.out.print("skriv row index: ");
Scanner sc_index = new Scanner(System.in);
int index = sc_index.nextInt();
System.out.print("row index("+index+") är: "+row.get(index));
}
return row;
}
}//c