private static void checkFilePattern ( String s ) throws ProblemException { // File names like foo/bar/gamma/Bar.java are allowed, // as well as /bar/jndi.properties as well as, // */bar/Foo.java Pattern p = null ; if ( File . separatorChar == ' ' ) { p = Pattern . compile ( "\\*?(.+\\\\)*.+" ) ; } else if ( File . separatorChar == ' ' ) { p = Pattern . compile ( "\\*?(.+/)*.+" ) ; } else { throw new ProblemException ( "This platform uses the unsupported " + File . separatorChar + " as file separator character. Please add support for it!" ) ; } Matcher m = p . matcher ( s ) ; if ( ! m . matches ( ) ) { throw new ProblemException ( "The string \"" + s + "\" is not a proper file name." ) ; } }
Verify that a source file name is valid .