Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample;
- /**
- * Created by vshevchenko on 22.11.2017.
- */
- import java.io.*;
- import java.nio.file.Paths;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- import java.util.StringTokenizer;
- public class Reader {
- static List<List<String>> rows;
- static final String FIELD_DELIMER = "|";
- public static List<List<String>> read() throws IOException {
- File file = new File("good.txt");
- rows = new ArrayList<List<String>>();
- System.out.println(file.getAbsolutePath());
- BufferedReader in = new BufferedReader(new FileReader(file));
- String line;
- StringTokenizer row;
- ArrayList<String> fields = new ArrayList<String>();
- while ((line = in.readLine()) != null){
- row = new StringTokenizer(line, FIELD_DELIMER);
- fields.clear();
- while (row.countTokens() != 0) {
- String field = row.nextToken();
- fields.add(field);
- System.out.print(field + "*");
- }
- rows.add(fields);
- System.out.println();
- }
- in.close();
- return rows;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement