public static Section readFirstSectionAndClose ( Reader reader , String titleToLookFor ) throws IOException { PemReader pemReader = new PemReader ( reader ) ; try { return pemReader . readNextSection ( titleToLookFor ) ; } finally { pemReader . close ( ) ; } }
Reads the first section in the PEM file optionally based on a title to look for and then closes the reader .