fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Scanner;
  6. import java.util.regex.Pattern;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. String s="Id: 1\r\n" +
  14. "Raw Value: 1234\r\n" +
  15. "Processed Value{423}: A3s2344\r\n" +
  16. "\r\n" +
  17. "Id: 36\r\n" +
  18. "Raw Value: 389001\r\n" +
  19. "Processed Value{2}: \"Access Success\"\r\n" +
  20. "\r\n" +
  21. "Id: 28934\r\n" +
  22. "Raw Value: 2402\r\n" +
  23. "Processed Value: 1345.2 seconds";
  24.  
  25. List<String> list = new ArrayList<>();
  26. Scanner scanner = new Scanner(s);
  27. Pattern pattern = Pattern.compile("(\r?\n){2,}", Pattern.UNIX_LINES);
  28. scanner.useDelimiter(pattern);
  29.  
  30. while (scanner.hasNext()) {
  31. list.add(scanner.next());
  32. }
  33. for (String data : list) {
  34. System.out.println(data);
  35. System.out.println("------------------");
  36. }
  37. scanner.close();
  38. }
  39. }
Success #stdin #stdout 0.1s 380736KB
stdin
Standard input is empty
stdout
Id: 1
Raw Value: 1234
Processed Value{423}: A3s2344
------------------
Id: 36
Raw Value: 389001
Processed Value{2}: "Access Success"
------------------
Id: 28934
Raw Value: 2402
Processed Value: 1345.2 seconds
------------------