Split a String in Java
<p>I am using the Java exec command to issue a "hcitool scan" command in order to perform a Bluetooth Scan. </p>

<p>The output is in the exact same format as it would be if i were to type in the command to the terminal </p>

<pre><code>scanning...
mac address      bluetoothName
Done
</code></pre>

<p>I want to be able to split the returned string down, so that i can store the found MAC Addresses as a String.</p>

<p>My code so far is as follows:</p>

<pre><code>import java.io.*;

public class altBluetooth
{
  public static void main(String args[])
  {
    try
    {
      Process p=Runtime.getRuntime().exec("hcitool scan");
      p.waitFor();
      BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
      String line=reader.readLine();

      while(line!=null)
      {
        System.out.println(line);
        line=reader.readLine();
      }
    }
    catch(IOException e1) {
      System.out.print("This didnt work - exception 1");
    }
    catch(InterruptedException e2) {
      System.out.print("This didnt work - exception 2");
    }

    System.out.println("Done");
  }
} 
</code></pre>
