|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Writer
org.eobjects.metamodel.util.UnicodeWriter
public class UnicodeWriter
Writes Unicode text to an output stream. If the specified encoding is a
Unicode, then the text is preceeded by the proper Unicode BOM. If it is any
other encoding, this class behaves just like OutputStreamWriter.
This class is here because Java's OutputStreamWriter apparently
doesn't believe in writing BOMs.
For optimum performance, it is recommended that you wrap all instances of
UnicodeWriter with a java.io.BufferedWriter.
This file is a redistribution of Rubert Futrell from FifeSoft UnicodeWriter
(also LGPL licensed).
UnicodeWriter.java - Writes Unicode output with the proper BOM. Copyright (C) 2004 Robert Futrell robert_futrell at users.sourceforge.net http://fifesoft.com/rsyntaxtextarea
| Field Summary | |
|---|---|
static byte[] |
UTF16BE_BOM
|
static byte[] |
UTF16LE_BOM
|
static byte[] |
UTF32BE_BOM
|
static byte[] |
UTF32LE_BOM
|
static byte[] |
UTF8_BOM
|
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
UnicodeWriter(File file,
String encoding)
This is a utility constructor since the vast majority of the time, this class will be used to write Unicode files. |
|
UnicodeWriter(OutputStream outputStream,
String encoding)
Creates a new writer. |
|
UnicodeWriter(String fileName,
String encoding)
This is a utility constructor since the vast majority of the time, this class will be used to write Unicode files. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this writer. |
void |
flush()
Flushes the stream. |
void |
write(char[] cbuf,
int off,
int len)
Writes a portion of an array of characters. |
void |
write(int c)
Writes a single character. |
void |
write(String str,
int off,
int len)
Writes a portion of a string. |
| Methods inherited from class java.io.Writer |
|---|
append, append, append, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte[] UTF8_BOM
public static final byte[] UTF16LE_BOM
public static final byte[] UTF16BE_BOM
public static final byte[] UTF32LE_BOM
public static final byte[] UTF32BE_BOM
| Constructor Detail |
|---|
public UnicodeWriter(String fileName,
String encoding)
throws UnsupportedEncodingException,
IOException
fileName - The file to which to write the Unicode output.encoding - The encoding to use.
UnsupportedEncodingException - If the specified encoding is not supported.
IOException - If an IO exception occurs.
public UnicodeWriter(File file,
String encoding)
throws UnsupportedEncodingException,
IOException
file - The file to which to write the Unicode output.encoding - The encoding to use.
UnsupportedEncodingException - If the specified encoding is not supported.
IOException - If an IO exception occurs.
public UnicodeWriter(OutputStream outputStream,
String encoding)
throws UnsupportedEncodingException,
IOException
outputStream - The output stream to write.encoding - The encoding to use.
UnsupportedEncodingException - If the specified encoding is not supported.
IOException - If an IO exception occurs.| Method Detail |
|---|
public void close()
throws IOException
close in interface Closeableclose in class WriterIOException - If an IO exception occurs.
public void flush()
throws IOException
flush in interface Flushableflush in class WriterIOException - If an IO exception occurs.
public void write(char[] cbuf,
int off,
int len)
throws IOException
write in class Writercbuf - The buffer of characters.off - The offset from which to start writing characters.len - The number of characters to write.
IOException - If an I/O error occurs.
public void write(int c)
throws IOException
write in class Writerc - An integer specifying the character to write.
IOException - If an IO error occurs.
public void write(String str,
int off,
int len)
throws IOException
write in class Writerstr - The string from which to write.off - The offset from which to start writing characters.len - The number of characters to write.
IOException - If an IO error occurs.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||