fork(2) download
  1. class Example
  2. {
  3. public static void main (String[] args) throws java.lang.Exception
  4. {
  5. String pdfName = "abc-def.ghi";
  6.  
  7. // Without escaping
  8. String[] tokens1 = pdfName.split("[-.]");
  9. for (String token : tokens1) {
  10. System.out.println(token);
  11. }
  12.  
  13. // With escaping, even though we don't have to do it
  14. String[] tokens2 = pdfName.split("[\\-\\.]");
  15. for (String token : tokens2) {
  16. System.out.println(token);
  17. }
  18. }
  19. }
Success #stdin #stdout 0.09s 47980KB
stdin
Standard input is empty
stdout
abc
def
ghi
abc
def
ghi