/** * Instantiates a zip encoding. * * @param name The name of the zip encoding. Specify <code>null</code> for * the platform's default encoding. * @return A zip encoding for the given encoding name. */ protected internal static ZipEncoding getZipEncoding(String name) { // fallback encoding is good enough for utf-8. if (isUTF8(name)) { return(UTF8_ZIP_ENCODING); } if (name == null) { return(new FallbackZipEncoding()); } SimpleEncodingHolder h = (SimpleEncodingHolder)simpleEncodings.get(name); if (h != null) { return(h.getEncoding()); } try { java.nio.charset.Charset cs = java.nio.charset.Charset.forName(name); return(new NioZipEncoding(cs)); } catch (java.nio.charset.UnsupportedCharsetException) { return(new FallbackZipEncoding(name)); } }
/* * Constructs a new InputStreamReader on the InputStream {@code in} and * Charset {@code charset}. * * @param in * the source InputStream from which to read characters. * @param charset * the Charset that defines the character converter */ public InputStreamReader(InputStream inJ, java.nio.charset.Charset charset) : base(inJ) { this.inJ = inJ; decoder = charset.newDecoder().onMalformedInput( java.nio.charset.CodingErrorAction.REPLACE).onUnmappableCharacter( java.nio.charset.CodingErrorAction.REPLACE); bytes.limit(0); }
/* * Determines whether this charset is a super set of the given charset. * * @param charset * a given charset. * @return true if this charset is a super set of the given charset, * false if it's unknown or this charset is not a superset of * the given charset. */ public override bool contains(java.nio.charset.Charset charset) { return(false); }
public OutputStreamWriter(OutputStream outJ, String charsetName) { cs = java.nio.charset.Charset.forName(charsetName); this.delegateInstance = outJ; }
/** * Construct an NIO based zip encoding, which wraps the given * charset. * * @param charset The NIO charset to wrap. */ public NioZipEncoding(java.nio.charset.Charset charset) { this.charset = charset; }