type - the type identifier in the PEM header without PEM syntax labels. For a public key, type would be "PUBLIC KEY".content - the Base64-encoded data, excluding the PEM header and footerleadingData - any non-PEM data preceding the PEM header when decoding.DEREncodablePREVIEWpublic record PEMRecord(String type, String content, byte[] leadingData) extends Record implements DEREncodablePREVIEW
PEMRecord is a preview API of the Java platform. PEMRecord is a DEREncodablePREVIEW that represents Privacy-Enhanced Mail (PEM) data by its type and Base64 form. PEMDecoderPREVIEW and PEMEncoderPREVIEW use PEMRecord when representing the data as a cryptographic object is not desired or the type has no DEREncodable. type and content may not be null. leadingData may be null if no non-PEM data preceded PEM header during decoding. leadingData may be useful for reading metadata that accompanies PEM data.
No validation is performed during instantiation to ensure that type conforms to RFC 7468, that content is valid Base64, or that content matches the type. leadingData is not defensively copied and does not return a clone when leadingData() is called.
| Constructor | Description |
|---|---|
PEMRecord |
Creates a PEMRecord instance with a given type and content data in String form. |
PEMRecord |
Creates a PEMRecord instance with the given parameters. |
| Modifier and Type | Method | Description |
|---|---|---|
String |
content() |
Returns the value of the content record component. |
final boolean |
equals |
Indicates whether some other object is "equal to" this one. |
final int |
hashCode() |
Returns a hash code value for this object. |
byte[] |
leadingData() |
Returns the value of the leadingData record component. |
String |
toString() |
Returns the type and Base64 encoding in PEM format. |
String |
type() |
Returns the value of the type record component. |
public PEMRecord(String type, String content, byte[] leadingData)
PEMRecord instance with the given parameters.type - the type identifiercontent - the Base64-encoded data, excluding the PEM header and footerleadingData - any non-PEM data read during the decoding process before the PEM header. This value maybe null.IllegalArgumentException - if type is incorrectly formatted.NullPointerException - if type and/or content are null.public PEMRecord(String type, String content)
PEMRecord instance with a given type and content data in String form. leadingData is set to null.type - the PEM type identifiercontent - the Base64-encoded data, excluding the PEM header and footerIllegalArgumentException - if type is incorrectly formatted.NullPointerException - if type and/or content are null.public final boolean equals(Object o)
Objects::equals(Object,Object).public byte[] leadingData()
leadingData record component.leadingData record component
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/security/PEMRecord.html
PEMRecordwhen preview features are enabled.