Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void readFile(String filename, ArrayList<Automobilis> autombiliai) throws IOException {
- String[][] root;
- List<String> lines = Files.readAllLines(Paths.get(filename), StandardCharsets.UTF_8);
- root = new String[lines.size()][];
- lines.removeAll(Arrays.asList("", null));
- for (int i = 0; i < lines.size(); i++) {
- root[i] = lines.get(i).split(";");
- }
- ArrayList<String> gamintojai = new ArrayList<>();
- ArrayList<String> modeliai = new ArrayList<>();
- ArrayList<Double> variklioTuris = new ArrayList<>();
- ArrayList<Integer> variklioGalia = new ArrayList<>();
- for (int i = 0; i < lines.size(); i++) {
- for (int j = 0; j < lines.size(); j++) {
- String data = replaceWhiteSpaces(root[i][j]);
- if (i == 0) {
- gamintojai.add(replaceWhiteSpaces(root[i][j]));
- } else if (i == 1) {
- modeliai.add(root[i][j]);
- } else if (i == 2) {
- double value = Double.parseDouble(replaceWhiteSpaces(root[i][j]));
- variklioTuris.add(value);
- } else if (i == 3) {
- int val = Integer.parseInt(replaceWhiteSpaces(root[i][j]));
- variklioGalia.add(val);
- }
- }
- }
- for (int i = 0; i < gamintojai.size(); i++) {
- Automobilis automobilis = new Automobilis(gamintojai.get(i), modeliai.get(i), variklioTuris.get(i), variklioGalia.get(i));
- autombiliai.add(automobilis);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement