public static String readPemStringFromFile(File file){
  try {
    byte[] fileContents=FileUtils.readFileToByteArray(file);
    return new String(fileContents,Charset.forName("US-ASCII"));
  }
 catch (  IOException e) {
    throw new ImportException("Unable to read PEM-encoded data from file: " + file.getName());
  }
}

public static String readPemStringFromFile ( File file ) { try { byte [ ] fileContents = FileUtils . readFileToByteArray ( file ) ; return new String ( fileContents , Charset . forName ( "US-ASCII" ) ) ; } catch ( IOException e ) { throw new ImportException ( "Unable to read PEM-encoded data from file: " + file . getName ( ) ) ; } }
convenience method to read pem data from a file . the file encoding must be us_ascii .
