title: Reading integers from text files in java and then finding the median
body: <p>I'm really stuck with this, not sure how to do it.</p>
  
  <p>What I want to do is read as input a set of numbers from a text file.</p>
  
  <p>For example.</p>
  
  <pre><code>4
  1
  2
  3
  4
  </code></pre>
  
  <p>The first line contains <code>N</code>, the count of numbers. <code>N</code> lines follow.</p>
  
  <p>If N is even, then --><code>N/2</code>. In this case 4/2 = 2. From that we find the 2nd smallest number of the list. This is the output.</p>
  
  <p>If N is odd, then --> <code>N+1/2</code>, and do the same. </p>
  
  <p>How do I do this? I have this so far but I don't know how to sort it and read it into an array. </p>
  
  <p>I've stumbled my way onto this. I really am just taking shots in the dark.</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.InputStreamReader;
  
  class TestClass {
  
      public static void main(String args[]) throws Exception {
  
          // read number of data from system standard input. 
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          String line = br.readLine();
          int N = Integer.parseInt(line);
          // median sum 
          long SumMedians = 0;
  
          {
              int[] MyArray = new int[N];
              for (int i = 0; i &lt; N; i++) {
                  MyArray[i] = Integer.parseInt(br.readLine());
              }
          }
  
          // write output to system standard output 
          System.out.println(SumMedians % 100000);
          System.out.println(MyArray);
  
      }
  }
  </code></pre>