fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.util.stream.* ;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. String input = "so ow - 00250 = 00000000 ]" ;
  15. String output =
  16. .stream( input.split( " " ) )
  17. .filter( s -> ! s.isBlank() )
  18. .map(
  19. s -> {
  20. try{
  21. int x = Integer.parseInt( s ) ;
  22. return String.valueOf( x ) ;
  23. } catch ( NumberFormatException e ) {
  24. return s ; // Swallow the exception.
  25. }
  26. }
  27. )
  28. .collect( Collectors.joining( " " ) )
  29. ;
  30. System.out.println( output ) ;
  31. }
  32. }
Success #stdin #stdout 0.1s 48184KB
stdin
Standard input is empty
stdout
so ow - 250 = 0 ]