public static File getOrCreateFile ( String url , boolean createIfNotFound ) throws IOException { File file = null ; if ( url . contains ( ResourceUtils . CLASSPATH_URL_PREFIX ) ) { url = url . replaceAll ( ResourceUtils . CLASSPATH_URL_PREFIX , "" ) ; if ( url . startsWith ( "/" ) ) { url = url . substring ( 1 ) ; } URL resource = SenBotContext . class . getClassLoader ( ) . getResource ( "" ) ; if ( resource == null ) { throw new IOException ( "creating a new folder on the classpath is not allowed" ) ; } else { file = new File ( resource . getFile ( ) + "/" + url ) ; } } else { file = new File ( url ) ; } if ( createIfNotFound && ! file . exists ( ) ) { file . mkdirs ( ) ; } return file ; }
Get a File on the class path or file system or create it if it does not exist