Type.PUBLIC/"X.509" - gets a KeyFactory instance for
the key algorithm, constructs an X509EncodedKeySpec with the
encoded key bytes, and generates a public key from the spec

Type.PRIVATE/"PKCS#8" - gets a KeyFactory instance for
the key algorithm, constructs a PKCS8EncodedKeySpec with the
encoded key bytes, and generates a private key from the spec

Returns:

the resolved Key object

Throws:

ObjectStreamException - if the Type/format
combination is unrecognized, if the algorithm, key format, or
encoded key bytes are unrecognized/invalid, of if the
resolution of the key fails for any reason

Submit a bug or featureFor further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.