title: How to sort Integers from Files
body: <p>I am trying to take input from File1(.txt) and File2(.txt), combine and sort the Integers contained in both files and create a third File3(.txt), containing the sorted integers from files 1 and 2.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>    File input1 = new File("H:\\Desktop\\input1.txt");
      Scanner scan = new Scanner(input1);
  
      File input2 = new File("H:\\Desktop\\input2.txt");
      int num;
  
      while(scan.hasNextInt())
      {
          num = scan.nextInt();
  
          final List&lt;Integer&gt; list = Arrays.asList(num);
          Collections.sort(list);
          System.out.println(list);
      }
  </code></pre>
  
  <p>File1 contains numbers 10, 11, 8, 74, 16.
  Every array I try, I have always gotten Gibberish output, So I have resulted in this code. I get output but its not sorted:</p>
  
  <pre><code>[10]
  [11]
  [8]
  [74]
  [16]
  </code></pre>
  
  <p>Can anyone help and or give advice?</p>