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. /* 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.  
  13. String input = " this*is#a*&very_dirty&String" ;
  14. String onlyLetters =
  15. input
  16. .codePoints()
  17. .filter(
  18. codePoint -> Character.isLetter( codePoint )
  19. )
  20. .collect(
  21. StringBuilder :: new ,
  22. StringBuilder :: appendCodePoint ,
  23. StringBuilder :: append
  24. )
  25. .toString()
  26. ;
  27.  
  28. System.out.println( onlyLetters ) ;
  29.  
  30. }
  31. }
Success #stdin #stdout 0.12s 48776KB
stdin
Standard input is empty
stdout
thisisaverydirtyString