本文整理汇总了Java中sun.nio.cs.ThreadLocalCoders类的典型用法代码示例。如果您正苦于以下问题:Java ThreadLocalCoders类的具体用法?Java ThreadLocalCoders怎么用?Java ThreadLocalCoders使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ThreadLocalCoders类属于sun.nio.cs包,在下文中一共展示了ThreadLocalCoders类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import sun.nio.cs.ThreadLocalCoders; //导入依赖的package包/类
/**
* Convenience method that decodes bytes in this charset into Unicode
* characters.
*
* <p> An invocation of this method upon a charset <tt>cs</tt> returns the
* same result as the expression
*
* <pre>
* cs.newDecoder()
* .onMalformedInput(CodingErrorAction.REPLACE)
* .onUnmappableCharacter(CodingErrorAction.REPLACE)
* .decode(bb); </pre>
*
* except that it is potentially more efficient because it can cache
* decoders between successive invocations.
*
* <p> This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement byte array. In order
* to detect such sequences, use the {@link
* CharsetDecoder#decode(java.nio.ByteBuffer)} method directly. </p>
*
* @param bb The byte buffer to be decoded
*
* @return A char buffer containing the decoded characters
*/
public final CharBuffer decode(ByteBuffer bb) {
try {
return ThreadLocalCoders.decoderFor(this)
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.decode(bb);
} catch (CharacterCodingException x) {
throw new Error(x); // Can't happen
}
}
示例2: encode
import sun.nio.cs.ThreadLocalCoders; //导入依赖的package包/类
/**
* Convenience method that encodes Unicode characters into bytes in this
* charset.
*
* <p> An invocation of this method upon a charset <tt>cs</tt> returns the
* same result as the expression
*
* <pre>
* cs.newEncoder()
* .onMalformedInput(CodingErrorAction.REPLACE)
* .onUnmappableCharacter(CodingErrorAction.REPLACE)
* .encode(bb); </pre>
*
* except that it is potentially more efficient because it can cache
* encoders between successive invocations.
*
* <p> This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. In order to
* detect such sequences, use the {@link
* CharsetEncoder#encode(java.nio.CharBuffer)} method directly. </p>
*
* @param cb The char buffer to be encoded
*
* @return A byte buffer containing the encoded characters
*/
public final ByteBuffer encode(CharBuffer cb) {
try {
return ThreadLocalCoders.encoderFor(this)
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.encode(cb);
} catch (CharacterCodingException x) {
throw new Error(x); // Can't happen
}
}
示例3: decode
import sun.nio.cs.ThreadLocalCoders; //导入依赖的package包/类
/**
* Convenience method that decodes bytes in this charset into Unicode
* characters.
*
* <p> An invocation of this method upon a charset {@code cs} returns the
* same result as the expression
*
* <pre>
* cs.newDecoder()
* .onMalformedInput(CodingErrorAction.REPLACE)
* .onUnmappableCharacter(CodingErrorAction.REPLACE)
* .decode(bb); </pre>
*
* except that it is potentially more efficient because it can cache
* decoders between successive invocations.
*
* <p> This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement byte array. In order
* to detect such sequences, use the {@link
* CharsetDecoder#decode(java.nio.ByteBuffer)} method directly. </p>
*
* @param bb The byte buffer to be decoded
*
* @return A char buffer containing the decoded characters
*/
public final CharBuffer decode(ByteBuffer bb) {
try {
return ThreadLocalCoders.decoderFor(this)
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.decode(bb);
} catch (CharacterCodingException x) {
throw new Error(x); // Can't happen
}
}
示例4: encode
import sun.nio.cs.ThreadLocalCoders; //导入依赖的package包/类
/**
* Convenience method that encodes Unicode characters into bytes in this
* charset.
*
* <p> An invocation of this method upon a charset {@code cs} returns the
* same result as the expression
*
* <pre>
* cs.newEncoder()
* .onMalformedInput(CodingErrorAction.REPLACE)
* .onUnmappableCharacter(CodingErrorAction.REPLACE)
* .encode(bb); </pre>
*
* except that it is potentially more efficient because it can cache
* encoders between successive invocations.
*
* <p> This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. In order to
* detect such sequences, use the {@link
* CharsetEncoder#encode(java.nio.CharBuffer)} method directly. </p>
*
* @param cb The char buffer to be encoded
*
* @return A byte buffer containing the encoded characters
*/
public final ByteBuffer encode(CharBuffer cb) {
try {
return ThreadLocalCoders.encoderFor(this)
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.encode(cb);
} catch (CharacterCodingException x) {
throw new Error(x); // Can't happen
}
}
示例5: decode
import sun.nio.cs.ThreadLocalCoders; //导入依赖的package包/类
/**
* Convenience method that decodes bytes in this charset into Unicode
* characters.
*
* <p> An invocation of this method upon a charset <tt>cs</tt> returns the
* same result as the expression
*
* <pre>
* cs.newDecoder()
* .onMalformedInput(CodingErrorAction.REPLACE)
* .onUnmappableCharacter(CodingErrorAction.REPLACE)
* .decode(bb); </pre>
*
* except that it is potentially more efficient because it can cache
* decoders between successive invocations.
*
* <p> This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement byte array. In order
* to detect such sequences, use the {@link
* CharsetDecoder#decode(java.nio.ByteBuffer)} method directly. </p>
*
* @param bb The byte buffer to be decoded
*
* @return A char buffer containing the decoded characters
*/
public final CharBuffer decode(ByteBuffer bb) {
try {
return ThreadLocalCoders.decoderFor(this)
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.decode(bb);
} catch (CharacterCodingException x) {
throw new Error(x); // Can't happen
}
}
示例6: encode
import sun.nio.cs.ThreadLocalCoders; //导入依赖的package包/类
/**
* Convenience method that encodes Unicode characters into bytes in this
* charset.
*
* <p> An invocation of this method upon a charset <tt>cs</tt> returns the
* same result as the expression
*
* <pre>
* cs.newEncoder()
* .onMalformedInput(CodingErrorAction.REPLACE)
* .onUnmappableCharacter(CodingErrorAction.REPLACE)
* .encode(bb); </pre>
*
* except that it is potentially more efficient because it can cache
* encoders between successive invocations.
*
* <p> This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. In order to
* detect such sequences, use the {@link
* CharsetEncoder#encode(java.nio.CharBuffer)} method directly. </p>
*
* @param cb The char buffer to be encoded
*
* @return A byte buffer containing the encoded characters
*/
public final ByteBuffer encode(CharBuffer cb) {
try {
return ThreadLocalCoders.encoderFor(this)
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.encode(cb);
} catch (CharacterCodingException x) {
throw new Error(x); // Can't happen
}
}