Main

Läser in argument rad för rad.
mail@pastecode.io avatar
unknown
java
2 years ago
1.0 kB
4
Indexable
Never
package com.alt2;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    /*
    Main class. We'll read the file one line at a time, and save our arguments in a suitable container.
    In this case an ArrayList.

     */
    public static void main(String[] args) {

        ArrayList<String> commands = new ArrayList<>();
        Grid grid = new Grid();
        try {
            File myObj = new File("C:\\Users\\Gusta\\IdeaProjects\\RobotHiQ\\src\\com\\inputs\\input1.txt");
            Scanner myReader = new Scanner(myObj);
            while (myReader.hasNextLine()) {
                String data = myReader.nextLine();
                commands.add(data);

            }
            myReader.close();
        } catch (FileNotFoundException e) {
            System.out.println("An error occurred.");
            e.printStackTrace();
        }

        grid.handleCommand(commands);

    }
    }