org.marketcetera.util.unicode
Class UnicodeFileWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.marketcetera.util.unicode.UnicodeOutputStreamWriter
          extended by org.marketcetera.util.unicode.UnicodeFileWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class UnicodeFileWriter
extends UnicodeOutputStreamWriter

A UnicodeOutputStreamWriter which directs its output to a file. All constructors pass-thru to a UnicodeOutputStreamWriter constructor an OutputStream that is built using a FileOutputStream constructor.

Appending to an existing file is safe: if the file exists, and is non-empty, then no signature BOM is recorded (regardless of the specified or deduced signature/charset) because we assume that a BOM is already present. However, this class does not attempt to check that, in this case, the existing signature BOM and associated charset match the one supplied in the constructor.

Since:
0.6.0
Version:
$Id: UnicodeFileWriter.java 16154 2012-07-14 16:34:05Z colin $
Author:
tlerios@marketcetera.com

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
UnicodeFileWriter(File file)
          Creates a new writer using the given file, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(File) constructors.
UnicodeFileWriter(File file, boolean append)
          Creates a new writer using the given file, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(File,boolean) constructors.
UnicodeFileWriter(File file, boolean append, Reader reader)
          Creates a new writer using the given file and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(File,boolean) constructors.
UnicodeFileWriter(File file, boolean append, SignatureCharset requestedSignatureCharset)
          Creates a new writer using the given file and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(File,boolean) constructors.
UnicodeFileWriter(FileDescriptor fd)
          Creates a new writer using the given file descriptor, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(FileDescriptor) constructors.
UnicodeFileWriter(FileDescriptor fd, Reader reader)
          Creates a new writer using the given file descriptor and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(FileDescriptor) constructors.
UnicodeFileWriter(FileDescriptor fd, SignatureCharset requestedSignatureCharset)
          Creates a new writer using the given file descriptor and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(FileDescriptor) constructors.
UnicodeFileWriter(File file, Reader reader)
          Creates a new writer using the given file and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(File) constructors.
UnicodeFileWriter(File file, SignatureCharset requestedSignatureCharset)
          Creates a new writer using the given file and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(File) constructors.
UnicodeFileWriter(String fileName)
          Creates a new writer using the given file name, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(String) constructors.
UnicodeFileWriter(String fileName, boolean append)
          Creates a new writer using the given file name, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(String,boolean) constructors.
UnicodeFileWriter(String fileName, boolean append, Reader reader)
          Creates a new writer using the given file name and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(String,boolean) constructors.
UnicodeFileWriter(String fileName, boolean append, SignatureCharset requestedSignatureCharset)
          Creates a new writer using the given file name and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(String,boolean) constructors.
UnicodeFileWriter(String fileName, Reader reader)
          Creates a new writer using the given file name and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(String) constructors.
UnicodeFileWriter(String fileName, SignatureCharset requestedSignatureCharset)
          Creates a new writer using the given file name and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(String) constructors.
 
Method Summary
 
Methods inherited from class org.marketcetera.util.unicode.UnicodeOutputStreamWriter
append, append, append, close, flush, getRequestedSignatureCharset, getSignatureCharset, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnicodeFileWriter

public UnicodeFileWriter(String fileName)
                  throws FileNotFoundException
Creates a new writer using the given file name, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(String) constructors.

Parameters:
fileName - The file name.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(String fileName,
                         SignatureCharset requestedSignatureCharset)
                  throws FileNotFoundException
Creates a new writer using the given file name and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(String) constructors.

Parameters:
fileName - The file name.
requestedSignatureCharset - The signature/charset. It may be null to use the default JVM charset.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(String fileName,
                         Reader reader)
                  throws IOException
Creates a new writer using the given file name and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(String) constructors.

Parameters:
fileName - The file name.
reader - The reader.
Throws:
IOException - Thrown if an I/O error occurs, incl. propagation from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(String fileName,
                         boolean append)
                  throws FileNotFoundException
Creates a new writer using the given file name, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(String,boolean) constructors.

Parameters:
fileName - The file name.
append - True if data should be appended to the file.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(String fileName,
                         boolean append,
                         SignatureCharset requestedSignatureCharset)
                  throws FileNotFoundException
Creates a new writer using the given file name and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(String,boolean) constructors.

Parameters:
fileName - The file name.
append - True if data should be appended to the file.
requestedSignatureCharset - The signature/charset. It may be null to use the default JVM charset.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(String fileName,
                         boolean append,
                         Reader reader)
                  throws IOException
Creates a new writer using the given file name and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(String,boolean) constructors.

Parameters:
fileName - The file name.
append - True if data should be appended to the file.
reader - The reader.
Throws:
IOException - Thrown if an I/O error occurs, incl. propagation from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(File file)
                  throws FileNotFoundException
Creates a new writer using the given file, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(File) constructors.

Parameters:
file - The file.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(File file,
                         SignatureCharset requestedSignatureCharset)
                  throws FileNotFoundException
Creates a new writer using the given file and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(File) constructors.

Parameters:
file - The file.
requestedSignatureCharset - The signature/charset. It may be null to use the default JVM charset.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(File file,
                         Reader reader)
                  throws IOException
Creates a new writer using the given file and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(File) constructors.

Parameters:
file - The file.
reader - The reader.
Throws:
IOException - Thrown if an I/O error occurs, incl. propagation from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(File file,
                         boolean append)
                  throws FileNotFoundException
Creates a new writer using the given file, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(File,boolean) constructors.

Parameters:
file - The file.
append - True if data should be appended to the file.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(File file,
                         boolean append,
                         SignatureCharset requestedSignatureCharset)
                  throws FileNotFoundException
Creates a new writer using the given file and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(File,boolean) constructors.

Parameters:
file - The file.
append - True if data should be appended to the file.
requestedSignatureCharset - The signature/charset. It may be null to use the default JVM charset.
Throws:
FileNotFoundException - Propagated from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(File file,
                         boolean append,
                         Reader reader)
                  throws IOException
Creates a new writer using the given file and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(File,boolean) constructors.

Parameters:
file - The file.
append - True if data should be appended to the file.
reader - The reader.
Throws:
IOException - Thrown if an I/O error occurs, incl. propagation from the FileOutputStream constructor.

UnicodeFileWriter

public UnicodeFileWriter(FileDescriptor fd)
Creates a new writer using the given file descriptor, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream) and FileOutputStream.FileOutputStream(FileDescriptor) constructors.

Parameters:
fd - The file descriptor.

UnicodeFileWriter

public UnicodeFileWriter(FileDescriptor fd,
                         SignatureCharset requestedSignatureCharset)
Creates a new writer using the given file descriptor and signature/charset, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, SignatureCharset) and FileOutputStream.FileOutputStream(FileDescriptor) constructors.

Parameters:
fd - The file descriptor.
requestedSignatureCharset - The signature/charset. It may be null to use the default JVM charset.

UnicodeFileWriter

public UnicodeFileWriter(FileDescriptor fd,
                         Reader reader)
                  throws IOException
Creates a new writer using the given file descriptor and reader, and the UnicodeOutputStreamWriter.UnicodeOutputStreamWriter(OutputStream, Reader) and FileOutputStream.FileOutputStream(FileDescriptor) constructors.

Parameters:
fd - The file descriptor.
reader - The reader.
Throws:
IOException - Thrown if an I/O error occurs.


Copyright © 2012. All Rights Reserved.