Class XMLReader

java.lang.Object
java.io.Reader
org.omegat.util.xml.XMLReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

@Deprecated(forRemoval=true, since="5.8") public class XMLReader extends Reader
Deprecated, for removal: This API element is subject to removal in a future version.
This class automatically detects encoding of an inner XML file and constructs a Reader with appropriate encoding.

Detecting of encoding is done by reading a value from XML header <?xml version="1.0" encoding="..."?>

If encoding isn't specified, or it is not supported by Java platform, the file is opened in default system encoding (ISO-8859-2 in USA, Windows-1251 on my OS).

  • Constructor Summary

    Constructors
    Constructor
    Description
    XMLReader(InputStream inputStream, String encoding)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    XMLReader(String fileName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a new instance of XMLReader.
    XMLReader(String fileName, String encoding)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a new instance of XMLReader.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int
    read(char[] cbuf, int off, int len)
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class java.io.Reader

    mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XMLReader

      public XMLReader(String fileName) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new instance of XMLReader. If encoding cannot be detected, falls back to default encoding of Operating System.
      Parameters:
      fileName - - the file to read
      Throws:
      IOException
    • XMLReader

      public XMLReader(String fileName, String encoding) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a new instance of XMLReader. If encoding cannot be detected, falls back to supplied encoding, or (if supplied null, or supplied encoding is not supported by JVM) falls back to default encoding of Operating System.
      Parameters:
      fileName - The file to read.
      encoding - The encoding to use if we can't autodetect.
      Throws:
      IOException
    • XMLReader

      public XMLReader(InputStream inputStream, String encoding) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Throws:
      IOException
  • Method Details

    • close

      public void close() throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Reader
      Throws:
      IOException
    • read

      public int read(char[] cbuf, int off, int len) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      read in class Reader
      Throws:
      IOException