Package org.omegat.filters2.html2
Class HTMLReader
- java.lang.Object
-
- java.io.Reader
-
- org.omegat.filters2.html2.HTMLReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class HTMLReader extends java.io.ReaderThis class automatically detects encoding of an inner HTML file and constructs a Reader with appropriate encoding. Detecting of encoding is done by reading a possible<META http-equiv="content-type" content="text/html; charset=...">and a value from XML header (in case there is one)<?xml version="1.0" encoding="..."?>. If encoding isn't specified, or it is not supported by Java platform, the file is opened in encoding passed to constructor or default system encoding (ISO-8859-2 in USA, Windows-1251 on my OS).
-
-
Constructor Summary
Constructors Constructor Description HTMLReader(java.lang.String fileName, java.lang.String encoding)Creates a new instance of HTMLReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.lang.StringgetEncoding()Returns encoding that was used to read the HTML file.intread(char[] cbuf, int off, int len)
-
-
-
Constructor Detail
-
HTMLReader
public HTMLReader(java.lang.String fileName, java.lang.String encoding) throws java.io.IOExceptionCreates a new instance of HTMLReader. If encoding cannot be detected, falls back to suppliedencoding, 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:
java.io.IOException
-
-
Method Detail
-
getEncoding
public java.lang.String getEncoding()
Returns encoding that was used to read the HTML file.
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader- Throws:
java.io.IOException
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException- Specified by:
readin classjava.io.Reader- Throws:
java.io.IOException
-
-