Code example for InvalidKeySpecException

            if (keySpec instanceof X509EncodedKeySpec) {
                return new DSAPublicKeyImpl((X509EncodedKeySpec) keySpec);
        throw new InvalidKeySpecException("'keySpec' is neither DSAPublicKeySpec nor X509EncodedKeySpec");
     * This method returns a specification for the supplied key. 
     * The specification will be returned in the form of an object of the type 
     * specified by keySpec. 
     * @param key - 
     *            either DSAPrivateKey or DSAPublicKey 
     * @param keySpec - 
     *            either DSAPrivateKeySpec.class or DSAPublicKeySpec.class 
     * @return either a DSAPrivateKeySpec or a DSAPublicKeySpec 
Stop searching for code, let great code find you!  Add Codota to your java IDE