public static PropertyFile find ( final ClassLoader classloader , final String ... fileNames ) { URL resolvedResource = null ; String resolvedFile = null ; for ( String fileName : fileNames ) { if ( fileName . charAt ( 0 ) == ' ' ) { File file = new File ( fileName ) ; if ( file . exists ( ) ) { try { return PropertyFile . readOnly ( file ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Error loading property file: " + fileName + ". Error: " + e . getMessage ( ) , e ) ; } } } else { // Try to resolve the filename (for logging any errors) final URL resource = classloader . getResource ( fileName ) ; if ( resource != null ) { resolvedFile = fileName ; resolvedResource = resource ; break ; } } } if ( resolvedFile == null ) { if ( fileNames . length == 1 ) throw new IllegalArgumentException ( "Error finding property file in classpath: " + fileNames [ 0 ] ) ; else throw new IllegalArgumentException ( "Error finding property files in classpath: " + Arrays . asList ( fileNames ) ) ; } else if ( log . isInfoEnabled ( ) ) log . info ( "{find} Loading properties from " + resolvedFile ) ; return openResource ( classloader , resolvedResource , resolvedFile ) ; }
Find a property file