private String getPemFileData ( ) throws IOException { final String methodName = "getPemFileData" ; logger . entry ( this , methodName ) ; if ( pemFileData != null ) { logger . exit ( this , methodName , pemFileData ) ; return pemFileData ; } final StringBuilder sb = new StringBuilder ( ) ; final InputStreamReader isr = new InputStreamReader ( new FileInputStream ( pemFile ) , "US-ASCII" ) ; try { int ch ; while ( ( ch = isr . read ( ) ) != - 1 ) { sb . append ( ( char ) ch ) ; } } finally { try { isr . close ( ) ; } catch ( IOException e ) { logger . data ( this , methodName , "Failed to close input stream reader. Reason: " , e ) ; } } pemFileData = sb . toString ( ) ; logger . exit ( this , methodName , pemFileData ) ; return pemFileData ; }
Read the PEM file data caching it locally such that the file is only read on first use .