Package org.omegat.filters2.html2
Class HTMLWriter
- java.lang.Object
-
- java.io.Writer
-
- org.omegat.filters2.html2.HTMLWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
public class HTMLWriter extends java.io.Writer
This class acts as an interceptor of output: First it collects all the output inside itself in a string. Then it adds a META with a given charset (or replaces the existing charset with a new one) and (if the file is XHTML and has XML header) adds encoding declaration (or replaces the encoding in the XML header). Next it writes out to the file.Note that if
encoding
parameter of theconstructor
is null, no encoding declaration is added, and the file is written in OS-default encoding. This is done to fix a bug [1.6 RC2] Bug with Target Encoding set to <auto> for (x)HTML.
-
-
Constructor Summary
Constructors Constructor Description HTMLWriter(java.lang.String fileName, java.lang.String encoding, HTMLOptions options)
Creates new HTMLWriter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Flushes the writer (which does the real write-out of data) and closes the real writer.void
flush()
Does the real write-out of the data, first adding/replacing encoding statement.void
write(char[] cbuf, int off, int len)
Write a portion of an array of characters.
-
-
-
Constructor Detail
-
HTMLWriter
public HTMLWriter(java.lang.String fileName, java.lang.String encoding, HTMLOptions options) throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException
Creates new HTMLWriter.- Parameters:
fileName
- - file name to write toencoding
- - the encoding to write HTML file in (null means OS-default encoding)- Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Flushes the writer (which does the real write-out of data) and closes the real writer.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Writer
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
Does the real write-out of the data, first adding/replacing encoding statement.- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in classjava.io.Writer
- Throws:
java.io.IOException
-
write
public void write(@NotNull char[] cbuf, int off, int len) throws java.io.IOException
Write a portion of an array of characters. Simply callswrite(char[], int, int)
of the internalStringWriter
.- Specified by:
write
in classjava.io.Writer
- Parameters:
cbuf
- - Array of charactersoff
- - Offset from which to start writing characterslen
- - Number of characters to write- Throws:
java.io.IOException
- - If an I/O error occurs
-
-