public static void write(final PrivateKey privateKey, final @NonNull OutputStream outputStream)
		throws IOException
	{
		final byte[] privateKeyBytes = privateKey.getEncoded();
		final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
		outputStream.write(keySpec.getEncoded());
		outputStream.close();
	}
public static void write ( final PrivateKey privateKey , final @ NonNull OutputStream outputStream ) throws IOException { final byte [ ] privateKeyBytes = privateKey . getEncoded ( ) ; final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec ( privateKeyBytes ) ; outputStream . write ( keySpec . getEncoded ( ) ) ; outputStream . close ( ) ; }
Write the given {@link PrivateKey} into the given {@link OutputStream} in the *.der format.

@param privateKey
the private key
@param outputStream
the output stream to write in
@throws IOException
Signals that an I/O exception has occurred.