Code example for StringWriter

Methods: closetoString

0
	assertTrue(key.isEncrypted());
 
    } 
 
    private String toString(OpenSSLKey key) throws Exception {
        StringWriter writer = new StringWriter();
        key.writeTo(writer);
        writer.close();
        String s = writer.toString();
        logger.debug(s);
        return s;
    } 
 
    public void testDecryptedToString() throws Exception { 
        KeyPair keyPair = getKeyPair();
	OpenSSLKey inKey = new BouncyCastleOpenSSLKey(keyPair.getPrivate());
	assertTrue(!inKey.isEncrypted());
         
        ByteArrayInputStream in = null;
        in = new ByteArrayInputStream(toString(inKey).getBytes());