title: Android: Split a string
body: <p>Solutions from all other similar threads crashes my app, that's why I had to create this thread. </p>
  
  <p>The string: </p>
  
  <pre><code>    FileInputStream fis = null;
      String collected = null;
      try {
          File file = new File(FILENAME);
          if(!file.exists())
          createfileinstantly();
          fis = openFileInput(FILENAME);
          byte[] dataArray = new byte [fis.available()];
          while (fis.read(dataArray) != -1)
             {
             collected = new String(dataArray); 
             } 
         ....
  </code></pre>
  
  <p>Here, "collected" is the string that I want to split. The default value of the string is: "0|0|0|0|0|0|0|0|0"
  So I want to use " | " to separate these values.</p>
  
  <p>When I add the following code after the above mentioned code, I get null 9 times:</p>
  
  <pre><code>    String[] separated = collected.split("|");
      String splay = separated[0];
      String swin = separated[1];
      String sall = separated[2];
      String sanimal = separated[3];
      String scountry = separated[4];
      String sfruit = separated[5];
      String shuman = separated[6];
      String soccupation = separated[7];
      String smisc = separated[8];
  </code></pre>
  
  <p>To  test the code I'm using a TextView called dataResults:</p>
  
  <pre><code>dataResults.setText(splay+swin+sall+sanimal+scountry+sfruit+shuman+soccupation+smisc);
  </code></pre>
  
  <p>I originally wanted to convert these strings to integer (I still want to) so at first I thought there was some problem while converting to integer. But after some testing out it turns that the issue is in splitting the strings. But just to be on the safer side after the main problem could you please add how to convert the split-ed strings to integer. </p>
  
  <p>Thank you very much!</p>
  
  <p><strong>EDIT:</strong> Even after changing "|" to "\\|" it is still showing "null" 9 times. <strong>Is that different enough?</strong></p>