资源简介
ByteToCharConverter.javaByteToCharConverter.javaByteToCharConverter.javaByteToCharConverter.javaByteToCharConverter.java
代码片段和文件信息
/*
* @(#)ByteToCharConverter.java 1.40 04/05/18
*
* Copyright 2004 Sun Microsystems Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package sun.io;
import java.io.*;
/**
* An abstract base class for subclasses which convert character data
* in an external encoding into Unicode characters.
*
* @author Asmus Freytag
* @author Lloyd Honomichl
*
* @deprecated Replaced by {@link java.nio.charset}. THIS API WILL BE
* REMOVED IN J2SE 1.6.
*/
@Deprecated
public abstract class ByteToCharConverter {
/*
* Substitution mode flag.
*/
protected boolean subMode = true;
/*
* Characters to use for automatic substitution.
*/
protected char[] subChars = { ‘\uFFFD‘ };
/*
* Offset of next character to be output
*/
protected int charOff;
/*
* Offset of next byte to be converted
*/
protected int byteOff;
/*
* Length of bad input that caused a MalformedInputException.
*/
protected int badInputLength;
/**
* Create an instance of the default ByteToCharConverter subclass.
*/
public static ByteToCharConverter getDefault() {
object cvt;
cvt = Converters.newDefaultConverter(Converters.BYTE_TO_CHAR);
return (ByteToCharConverter)cvt;
}
/**
* Returns appropriate ByteToCharConverter subclass instance.
* @param string represents encoding
*/
public static ByteToCharConverter getConverter(String encoding)
throws UnsupportedEncodingException
{
object cvt;
cvt = Converters.newConverter(Converters.BYTE_TO_CHAR encoding);
return (ByteToCharConverter)cvt;
}
/**
* Returns the character set id for the conversion
*/
public abstract String getCharacterEncoding();
/**
* Converts an array of bytes containing characters in an external
* encoding into an array of Unicode characters. This method allows
* a buffer by buffer conversion of a data stream. The state of the
* conversion is saved between calls to convert. Among other things
* this means multibyte input sequences can be split between calls.
* If a call to convert results in an exception the conversion may be
* continued by calling convert again with suitably modified parameters.
* All conversions should be finished with a call to the flush method.
*
* @return the number of bytes written to output.
* @param input byte array containing text to be converted.
* @param inStart begin conversion at this offset in input array.
* @param inEnd stop conversion at this offset in input array (exclusive).
* @param output character array to receive conversion result.
* @param outStart start writing to output array at this offset.
* @param outEnd stop writing to output array at this offset (exclusive).
* @exception MalformedInputException if the input buffer contains any
* sequence of bytes that is illegal for the
评论
共有 条评论