public static PrivKey load(File file,final String password) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, InvalidParameterSpecException {
  if (file.length() < 3)   throw new IllegalArgumentException("file is not a valid private key (too short file)");
  byte[] keyData=FileUtil.readFile(file);
  return load(keyData,password);
}

public static PrivKey load ( File file , final String password ) throws IOException , NoSuchAlgorithmException , InvalidKeySpecException , NoSuchPaddingException , InvalidKeyException , InvalidAlgorithmParameterException , IllegalBlockSizeException , BadPaddingException , InvalidParameterSpecException { if ( file . length ( ) < 3 ) throw new IllegalArgumentException ( "file is not a valid private key (too short file)" ) ; byte [ ] keyData = FileUtil . readFile ( file ) ; return load ( keyData , password ) ; }
load private key from a pem encoded file
