Package com.ms.xml.util
 In this topic

*Constructors

*Methods

 

Packages
  PreviousThis PackageNext
Package com.ms.xml.util   Previous This
Package
Next

 


Class XMLInputStream

public class XMLInputStream extends InputStream
{
  // Constructors
  public XMLInputStream( InputStream in );

  // Methods
  public XMLOutputStream createOutputStream( OutputStream out );
  public int read() throws IOException;
  public void setEncoding( String encoding ) throws IOException;
}

This class is an input stream reader, specifically designed to handle different encoding formats and little endian files.

InputStream
  |
  +--XMLInputStream

Constructors

XMLInputStream

public XMLInputStream( InputStream in );

Constructs an XMLInputStream object from an InputStream. The first four bytes of the InputStream are read to determine the character encoding of the file. The XMLInputStream object does not ensure that the input stream follows the XML standard, and expects any non-UTF-8 file to begin with a <?XML> tag.

ParameterDescription
in The input stream to base the XMLInputStream object on.

Methods

createOutputStream

public XMLOutputStream createOutputStream( OutputStream out );

Constructs an XMLOutputStream with the appropriate initial state. XMLOutputStream objects should always be created using this method for the output stream to mimic the input stream.

Return Value:

Returns a correctly initilized XMLOutputStream for use with the current XMLInputStream.

ParameterDescription
out The output stream to base the XMLOutputStream object on.

read

public int read() throws IOException;

Retrieves the next unicode character in the input stream. The read operation performed depends on the current read state.

Return Value:

Returns the next unicode character in the stream.

Exceptions:

IOException if an I/O error occurs.

setEncoding

public void setEncoding( String encoding ) throws IOException;

Defines the character encoding of the input stream.

Return Value:

No return value.

ParameterDescription
encoding The type of character encoding. This may be one of the following formats:
  • UTF-8
  • Shift_JIS
  • ISO-8859-1
  • ISO-10646-UCS-4 (not yet supported)
  • ISO-10646-UCS-2 or UCS-2

The default character encoding is ASCII.

Remarks:

The character encoding must agree with the encoding determined by the constructer. The setEncoding method is used to clarify encodings that are not fully determinable by reading the first four bytes in a stream. The method is not used to change the encoding of a stream. This method must be called within 4096 read() operations after the XMLInputStream object's creation.

Exceptions:

IOException if the encoding type is not supported by the currently installed virtual machine.

upnrm.gif