private List < String > getSchemaStringsFromJar ( String jarPath , String directoryPath ) { LOG . info ( "Getting schema strings in: " + directoryPath + ", from jar: " + jarPath ) ; JarFile jar ; try { jar = new JarFile ( URLDecoder . decode ( jarPath , "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { throw new DatasetException ( e ) ; } catch ( IOException e ) { throw new DatasetException ( e ) ; } Enumeration < JarEntry > entries = jar . entries ( ) ; List < String > schemaStrings = new ArrayList < String > ( ) ; while ( entries . hasMoreElements ( ) ) { JarEntry jarEntry = entries . nextElement ( ) ; if ( jarEntry . getName ( ) . startsWith ( directoryPath ) && jarEntry . getName ( ) . endsWith ( ".avsc" ) ) { LOG . info ( "Found schema: " + jarEntry . getName ( ) ) ; InputStream inputStream ; try { inputStream = jar . getInputStream ( jarEntry ) ; } catch ( IOException e ) { throw new DatasetException ( e ) ; } String schemaString = AvroUtils . inputStreamToString ( inputStream ) ; schemaStrings . add ( schemaString ) ; } } return schemaStrings ; }
Gets the list of HBase Common Avro schema strings from a directory in the Jar . It recursively searches the directory in the jar to find files that end in . avsc to locate thos strings .