How to scan text from a file and save into an array Java : <p>I am trying to read a string in from a text file, split the string whenever there are spaces, and store each word in an array of strings:</p>

<p>eg. input <code>"Hello i am a sentence"</code></p>

<p>output <code>[Hello, i, am, a, sentence]</code></p>

<p>I currently have the following</p>

<pre><code>Scanner sc = null;
      try
      {
        sc = new Scanner(new FileReader(args[0]));
        LinkedList&lt;String&gt; list = new LinkedList&lt;String&gt;();
        String str = sc.nextLine();
        for(String i:str.split(" ")){
           list.add(i);
        }
        String[] arguments = list.toArray(new String[list.size()]);
        System.out.println(arguments);
      }
      catch (FileNotFoundException e) {}
      finally
      {
          if (sc != null) sc.close();
      }
</code></pre>

<p>But i am unable to convert the list into an array and i get the following output</p>

<pre><code>[Ljava.lang.String;@45ee12a7
</code></pre>
