title: split it using java
body: <p>i need to split and string </p>
  
  <pre><code>    Sentence:NounPhrase| VerbPhrase
      NounPhrase:Art| Noun
      Sample:the 
  </code></pre>
  
  <p>this should be written As</p>
  
  <pre><code>Sentence:NounPhrase
  Sentence :VerbPhrase
  NounPhrase:Art
  NounPhrase: Noun
  Sample:the
  </code></pre>
  
  <p>how can i do this using java</p>
  
  <p>Edited</p>
  
  <p>the file <code>expression.txt</code></p>
  
  <pre><code>Sentence:NounPhrase VerbPhrase
  NounPhrase:Art Noun
  VerbPhrase:Verb|Adverb Verb
  Art:the|a
  Verb:jumps|sings
  Noun:dog|cat
  </code></pre>
  
  <p>the program i used but not working</p>
  
  <pre><code>   import java.io.BufferedReader;
  import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.InputStreamReader;
  import java.util.*;
  public class shift {
      public static String readFileFull(String file)
      {
           String strLine = null;
           StringBuffer sb = new StringBuffer();
  
          try{
  
              FileInputStream fstream = new FileInputStream(file);
  
              DataInputStream in = new DataInputStream(fstream);
  
              BufferedReader br = new BufferedReader(new InputStreamReader(in));
  
  
  
              while ((strLine = br.readLine()) != null)   {
                  sb.append("\n");      
                  sb.append(strLine);      
                  }
  
  
  
              in.close();
              }catch (Exception e){
                System.err.println("Error: " + e.getMessage());
              }
              String ret=sb.toString();
              return ret;
      }
  
      public static void main(String args[]) {
  
          String speech = readFileFull("c://expression.txt");
  
  
          StringBuilder sb = new StringBuilder();
          Scanner sc = new Scanner(speech);
  
          while (sc.hasNextLine()) {
              String[] ps = sc.nextLine().split(":");
              for (String s : (ps[1] + "|").split("\\|"))
                  if (!s.equals(""))
                      sb.append(ps[0]+":").append(s).append("\n");
          }
          System.out.println(sb.toString());
  
  
  
  
      }
  
  }
  </code></pre>
  
  <p>and try to tell me y i am still getting error</p>