This implementation is not favorable for encodings other than utf-8, because java.io encodes unmappable character as question marks leading to unreadable ZIP entries on some operating systems.
Furthermore this implementation is unable to tell whether a given name can be safely encoded or not.
This implementation acts as a last resort implementation, when
neither Simple8BitZipEncoding nor NioZipEncoding is
available.
The methods of this class are reentrant.
| Access | Constructor and Description |
|---|---|
| public | |
| public | FallbackZipEncoding(final String
The name of the charset or charset)null for
the platform's default character set.Construct a fallback zip encoding, which uses the given charset. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canEncode(final String
A filename or ZIP comment. name)Implements org. |
| public String | decode(final byte[]
The byte values to decode. data)Implements org. |
| public ByteBuffer | encode(final String
A filename or ZIP comment. name)Implements org. |
| charset | back to summary |
|---|---|
| private final String charset | |
| FallbackZipEncoding | back to summary |
|---|---|
| public FallbackZipEncoding() Construct a fallback zip encoding, which uses the platform's default charset. | |
| FallbackZipEncoding | back to summary |
|---|---|
| public FallbackZipEncoding(final String charset) Construct a fallback zip encoding, which uses the given charset.
| |
| canEncode | back to summary |
|---|---|
| public boolean canEncode(final String name) Implements org. Doc from org. Check, whether the given string may be losslessly encoded using this encoding.
| |
| decode | back to summary |
|---|---|
| public String decode(final byte[] data) throws IOException Implements org.
| |
| encode | back to summary |
|---|---|
| public ByteBuffer encode(final String name) throws IOException Implements org. Doc from org. Encode a filename or a comment to a byte array suitable for storing it to a serialized zip entry. Examples for CP 437 (in pseudo-notation, right hand side is C-style notation):
encode("€_for_Dollar.txt") = "%U20AC_for_Dollar.txt"
encode("Ölfässer.txt") = "\231lf\204sser.txt"
| |