fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String example = " sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode\n" +
  13. " 0: 00000000:04D2 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 15662 1 ffff8800baf1c780 100 0 0 10 0\n" +
  14. " 1: 00000000:04D2 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 15662 1 ffff8800baf1c780 100 0 0 10 0";
  15.  
  16. Scanner scanner = new Scanner(example);
  17. scanner.useRadix(16).useDelimiter("[\\s:]+");
  18. Set<Integer> result = new HashSet<>();
  19. scanner.next();
  20.  
  21. if (scanner.hasNextLine()) {
  22. // Skip the headers
  23. scanner.nextLine();
  24. }
  25. // Process records
  26. while (scanner.hasNextLine()) {
  27. // The first int
  28. if (scanner.hasNextInt()) {
  29. int slot = scanner.nextInt();
  30. System.out.println(slot);
  31.  
  32. // Read anything else you want from that line, until
  33. // you have only the newline left (or any trailing characters
  34. // you don't want to process and then the newline)
  35. }
  36.  
  37. // Clear the newline
  38. scanner.nextLine();
  39. }
  40.  
  41. System.out.println("Done");
  42. }
  43. }
Success #stdin #stdout 0.06s 711680KB
stdin
Standard input is empty
stdout
0
1
Done