@Beta public final class PemReader extends java.lang.Object
Beta
Supports reading any PEM stream that contains Base64 encoded content stored inside
"-----BEGIN ...-----" and "-----END ...-----" tags. Each call to
readNextSection() parses the next section in the PEM file. If you need a section of a
certain title use readNextSection(String), for example
readNextSection("PRIVATE KEY"). To ensure that the stream is closed properly, call
close() in a finally block.
As a convenience, use readFirstSectionAndClose(Reader) or
readFirstSectionAndClose(Reader, String) for the common case of only a single section in
a PEM file (or only a single section of a given title).
Limitations:
| Modifier and Type | Class and Description |
|---|---|
static class |
PemReader.Section
Section in the PEM file.
|
| Constructor and Description |
|---|
PemReader(java.io.Reader reader) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the reader.
|
static PemReader.Section |
readFirstSectionAndClose(java.io.Reader reader)
Reads the first section in the PEM file, and then closes the reader.
|
static PemReader.Section |
readFirstSectionAndClose(java.io.Reader reader,
java.lang.String titleToLookFor)
Reads the first section in the PEM file, optionally based on a title to look for, and then
closes the reader.
|
PemReader.Section |
readNextSection()
Reads the next section in the PEM file or
null for end of file. |
PemReader.Section |
readNextSection(java.lang.String titleToLookFor)
Reads the next section in the PEM file, optionally based on a title to look for.
|
public PemReader.Section readNextSection() throws java.io.IOException
null for end of file.java.io.IOExceptionpublic PemReader.Section readNextSection(java.lang.String titleToLookFor) throws java.io.IOException
titleToLookFor - title to look for or null for any titlenull for end of filejava.io.IOExceptionpublic static PemReader.Section readFirstSectionAndClose(java.io.Reader reader) throws java.io.IOException
reader - readernull for none foundjava.io.IOExceptionpublic static PemReader.Section readFirstSectionAndClose(java.io.Reader reader, java.lang.String titleToLookFor) throws java.io.IOException
titleToLookFor - title to look for or null for any titlereader - readernull for none foundjava.io.IOExceptionpublic void close()
throws java.io.IOException
To ensure that the stream is closed properly, call close() in a finally block.
java.io.IOExceptionCopyright © 2011-2018 Google. All Rights Reserved.