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.  
  11. public boolean validateFile(String fileName) {
  12. fileName = fileName.substring(0, fileName.lastIndexOf('.'));
  13. String[] values = fileName.split("_");
  14. if (values.length == 4) {
  15. if(!values[1].matches("0*")) {
  16. if(!fileName.contains(" ")) {
  17. if(values[3].equals("PASS") || values[3].equals("FAIL")) {
  18. return true;
  19. }
  20. }
  21. }
  22. }
  23. return false;
  24. }
  25.  
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28. Ideone ideone = new Ideone();
  29. String[] filenames = {"XYZZYXB20 v2_17133110134_201705171018.TXT",
  30. "XYZZYXB20 v2_00000000000_201705171148.TXT",
  31. "XYZZYX_00000000000_201706231531_FAIL.txt",
  32. "XYZZYXA20 v2_00000000000_201705171030.TXT",
  33. "XYZZYXB20v2_17133110134_201706231532_PASS.txt"};
  34. for(int i = 0; i < filenames.length; i++) {
  35. System.out.println(filenames[i] + ' ' + ideone.validateFile(filenames[i]));
  36. }
  37. }
  38. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
XYZZYXB20 v2_17133110134_201705171018.TXT false
XYZZYXB20 v2_00000000000_201705171148.TXT false
XYZZYX_00000000000_201706231531_FAIL.txt false
XYZZYXA20 v2_00000000000_201705171030.TXT false
XYZZYXB20v2_17133110134_201706231532_PASS.txt true