File Input/Output, Storing Data
<p>Alright, lets try this again, sorry for the poor title I don't know what to call this. I haven't done much File I/O before, I personally think Java is absolutely terrible at it but nonetheless I have to do it.</p>

<p>A bit of background information, this is my Conway's Game of Life project, and all of my other code works fine I just need to do the I/O now.</p>

<p>I'm reading in from a text file, that looks like <a href="http://gyazo.com/5f1e90acf0478668121c2598ebdce6d6.png?1361839710" rel="nofollow">this</a>.</p>

<p>So what this does is the first two numbers are the size of that the array needs to be, the String after them is irrelevant. And after that is the array of the cell arrangement in this example it's that of the glider. Now my problem is that I don't know how to store the first line in a String, and the rest in an array. Below is what I've done, and brace yourselves for a Big O of n^∞.</p>

<pre><code>    public char[][] fileIO(){
    ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
    char[][] newArray;
    String[] tokens;
    BufferedReader reader;
    String inputLine;

    try{
        reader = new BufferedReader(new FileReader("untitled.txt"));
        while((inputLine = reader.readLine()) != null){
            list.add(inputLine);
        }
        reader.close();
    }catch (IOException e){
        System.out.println(e);
    }

    tokens = list.get(0).trim().split("\\s+");
    newArray = new char[Integer.parseInt(tokens[0])][Integer.parseInt(tokens[1])];

    for(int row = 0; row &lt; newArray.length; row++){
        for(int col = 0; col &lt; newArray[row].length; col++){
            for(int line = 1; line &lt; list.size(); line++){
                for(int Char = 0; Char &lt; list.get(line).length(); Char++){
                    newArray[row][col] = list.get(line).charAt(Char);
                }
            }
        }
    }
    return newArray;
}
</code></pre>

<p>I know there's a lack of comments, so I'll try to explain what I tried to do now;</p>

<ul>
<li><p>I read from the file and stored it all in an ArrayList</p></li>
<li><p>Got the tokens of the first like (10 20 Glider), and created an instantiated an array with the values 10 and 20</p></li>
<li><p>Then proceeded to loop through the array's rows and columns, then each line of the inputted array, and then looped through each character of that line to add into the array at their respected positions.</p></li>
</ul>

<p>However, this doesn't seem to be working and I'm sure there is a much simpler and efficient way of doing this. So I ask again, can anyone tell me of a simpler way of doing this I/O? I don't need the code, just an explanation of how to do so.</p>
