public static PrivateKey readPemPrivateKey(final File file, final String algorithm)
		throws IOException, NoSuchAlgorithmException, InvalidKeySpecException,
		NoSuchProviderException
	{
		final String privateKeyAsString = readPemFileAsBase64(file);
		return readPemPrivateKey(privateKeyAsString, algorithm);
	}
public static PrivateKey readPemPrivateKey ( final File file , final String algorithm ) throws IOException , NoSuchAlgorithmException , InvalidKeySpecException , NoSuchProviderException { final String privateKeyAsString = readPemFileAsBase64 ( file ) ; return readPemPrivateKey ( privateKeyAsString , algorithm ) ; }
Reads the given {@link File}( in *.pem format) with given algorithm and returns the
{@link PrivateKey} object.

@param file
the file( in *.pem format) that contains the private key
@param algorithm
the algorithm
@return the {@link PrivateKey} object

@throws IOException
Signals that an I/O exception has occurred.
@throws NoSuchAlgorithmException
is thrown if instantiation of the SecretKeyFactory object fails.
@throws InvalidKeySpecException
is thrown if generation of the SecretKey object fails.
@throws NoSuchProviderException
is thrown if the specified provider is not registered in the security provider
list.