<p>You can get input from a file instead of from the terminal</p>
<pre><codeclass="language-java">FileInputStream fileIn = new FileInputStream("myFile.txt");
// Our familiar Scanner
Scanner scnr = new Scanner(fileIn);
// We can use our usual Scanner methods
String line = scnr.nextLine();
fileIn.close(); // Remember to close the file when you're finished with it!</code></pre>
<h3>Reviewing Scanner Methods</h3>
<p>To understand some of the Scanner methods we need to be aware of the "newline" character. This character is equivalent to the <code>Enter</code> button on the keyboard.</p>
<p><code>scnr.nextLine()</code> This get's all the characters in the buffer up to the newline character.</p>
<p><code>scnr.next()</code> Grabs the characters in the next "token". Tokens are usually separated by any whitespace type character (spaces, enters, tabs, etc.)</p>
<h2>Writing to a File</h2>
<p>Prints information to a file instead of to the screen</p>
<pre><codeclass="language-java">FileOutputStream fileOut = new FileOutputStream("myOutfile.txt");
PrintWriter out = new PrintWriter(fileOut);
out.println("Print this as the first line.");
out.flush(); // Pushes the file changes to the file
fileOut.close(); // If you forget this then it won't remember your changes</code></pre>
<h2>Arrays</h2>
<p>Arrays are containers of fixed size. It contains a fixed number of values of the <strong>same type</strong>. (Ex: 10 integers, 2 strings, 5 booleans)</p>
<p>Declaration</p>
<pre><codeclass="language-java">int[] array; // This declares an integer array</code></pre>
<p>Initialization</p>
<pre><codeclass="language-java">array = new int[7]; // This states that this array can hold up to 7 integers</code></pre>
<p>Storing a value in an array</p>
<ul>
<li>Square bracket notation is used</li>
</ul>
<pre><codeclass="language-java">int[] array = new int[7];
array[0] = 5; // Stores 5 into the first slot</code></pre>