CharsetEncoder


CharsetEncoder java.nio.charset

Java 1.4

A CharsetEncoder is an "encoding engine" that converts a sequence of characters into a sequence of bytes using some character encoding. Obtain a CharsetEncoder with the newEncoder( ) method of the Charset that represents the desired encoding.

A CharsetEncoder works like a CharsetDecoder in reverse. Use the encode( ) method to encode characters read from a CharBuffer into bytes stored in a ByteBuffer . Please see CharsetDecoder , which is documented in detail.

 public abstract class  CharsetEncoder  {  // Protected Constructors  protected  CharsetEncoder  (Charset  cs  ,          float  averageBytesPerChar  , float  maxBytesPerChar  );        protected  CharsetEncoder  (Charset  cs  ,          float  averageBytesPerChar  , float  maxBytesPerChar  , byte[ ]  replacement  );  // Public Instance Methods  public final float  averageBytesPerChar  ( );        public boolean  canEncode  (CharSequence  cs  );        public boolean  canEncode  (char  c  );        public final Charset  charset  ( );        public final java.nio.ByteBuffer  encode  (java.nio.CharBuffer  in  )          throws CharacterCodingException;        public final CoderResult  encode  (java.nio.CharBuffer  in  ,          java.nio.ByteBuffer  out  , boolean  endOfInput  );        public final CoderResult  flush  (java.nio.ByteBuffer  out  );        public boolean  isLegalReplacement  (byte[ ]  repl  );        public CodingErrorAction  malformedInputAction  ( );        public final float  maxBytesPerChar  ( );        public final CharsetEncoder  onMalformedInput  (CodingErrorAction  newAction  );        public final CharsetEncoder  onUnmappableCharacter  (CodingErrorAction  newAction  );        public final byte[ ]  replacement  ( );        public final CharsetEncoder  replaceWith  (byte[ ]  newReplacement  );        public final CharsetEncoder  reset  ( );        public CodingErrorAction  unmappableCharacterAction  ( );  // Protected Instance Methods  protected abstract CoderResult  encodeLoop  (java.nio.CharBuffer  in  ,          java.nio.ByteBuffer  out  );        protected CoderResult  implFlush  (java.nio.ByteBuffer  out  );        protected void  implOnMalformedInput  (CodingErrorAction  newAction  );  empty  protected void  implOnUnmappableCharacter  (CodingErrorAction  newAction  );  empty  protected void  implReplaceWith  (byte[ ]  newReplacement  );  empty  protected void  implReset  ( );  empty  } 

Passed To

java.io.OutputStreamWriter.OutputStreamWriter( ) , java.nio.channels.Channels.newWriter( )

Returned By

Charset.newEncoder( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net