fork download
  1. class Ideone
  2. {
  3. public static void main (String[] args) throws java.lang.Exception
  4. {
  5. String line = "word1|word2||||word3||word4|";
  6. String[] parts = line.split("\\|+");
  7. for (int i = 0; i < parts.length; i++) {
  8. System.out.println(parts[i]);
  9. }
  10. }
  11. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
word1
word2
word3
word4