Package com.iizix.util
Class XOutputFile
- java.lang.Object
- com.iizix.util.XOutputFile
public class XOutputFile extends java.lang.ObjectThis class is used for creating and writing to files that are stored using Phantom Hurricane in OEM ASCII or Ansi character set.
Field Summary
Fields Modifier and Type Field Description static byte[]isoNewLineThe New Line separator bytes for ISO character encoding.static java.lang.StringnewLineThe New Line separator.
Constructor Summary
Constructors Constructor Description XOutputFile()Creates a in-memory byte array output stream where the contents can be retrieved by means of getByteArrayOutputStream() or getByteArray() methods.XOutputFile(java.io.File file)Creates the specified file for write.XOutputFile(java.io.OutputStream out)Creates an instance for the output stream.XOutputFile(java.lang.String fileName)Creates the specified file for write.XOutputFile(java.lang.String fileName, XFile openFile)Creates the specified file for write.XOutputFile(java.lang.String fileName, java.lang.String previousFile)Creates the specified file for write.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close stream and filebyte[]getByteArray()Gets the written data as a byte array when the file refers to an in-memory file.java.io.ByteArrayOutputStreamgetByteArrayOutputStream()Gets the byte array output stream instance.java.io.DataOutputStreamgetDataOutputStream()Gets the data output stream instance.java.io.FileOutputStreamgetFileOutputStream()Gets the file output stream instance.java.io.OutputStreamgetOutputStream()Gets the file output stream instance.voidwriteByte(byte d)Write a byte to the file.voidwriteByte(int d)Write a byte to the file.voidwriteBytes(byte[] d)Write a byte array to the file.voidwriteBytes(byte[] d, int offset, int length)Write a byte array to the file.voidwriteIntelLong(int v)Writes an Intel formatted Long (32 bit value).voidwriteIntelShort(int v)Writes an Intel formatted Short (16 bit signed value).voidwriteIntelUShort(int v)Writes an Intel formatted UShort (16 bit unsigned value).voidwriteISOLine(java.lang.String line)Writes a string as a line in a file encoded in ISO 8859-1 character set.voidwriteLine(byte[] line)Writes an array of bytes to file and append line separator.voidwriteOEMString(java.lang.String s)Writes a string to its length using the OEM (ASCII) character set.voidwriteOEMString(java.lang.String s, int length, byte pad)Writes a string padded to the specified length with the padding character.voidwriteOEMString(java.lang.String s, int length, int pad)Writes a string padded to the specified length with the padding character.voidwriteOEMStringVector(java.util.Vector<java.lang.String> v)Converts a vector of unicode strings to ASCII bytes and writes them to file using environment dependent line separator.voidwriteString(java.lang.String s, int length, byte pad)Writes a string padded to the specified length with the padding character.voidwriteString(java.lang.String s, int length, int pad)Writes a string padded to the specified length with the padding character.voidwriteUnicodeString(java.lang.String s)Writes a string to its length in Unicode.voidwriteUnicodeString(java.lang.String s, int length, char pad)Writes a string padded to the specified length with the padding character.voidwriteZeroTermUnicodeString(java.lang.String s)Writes a zero-terminated Unicode string, if the string contains a zero-termination character, it will end there.
Constructor Detail
XOutputFile
public XOutputFile(java.io.File file) throws java.io.IOExceptionCreates the specified file for write.- Throws:
java.io.IOException- if an I/O error occurs.
XOutputFile
public XOutputFile(java.lang.String fileName) throws java.io.IOExceptionCreates the specified file for write.- Throws:
java.io.IOException- if an I/O error occurs.
XOutputFile
public XOutputFile(java.lang.String fileName, XFile openFile) throws java.io.IOExceptionCreates the specified file for write. The directory of the file name is taken from the instance of the PhantomFile passed into this method.- Throws:
java.io.IOException- if an I/O error occurs.
XOutputFile
public XOutputFile(java.lang.String fileName, java.lang.String previousFile) throws java.io.IOExceptionCreates the specified file for write. The directory of the file name is taken from the file name passed into this method.- Throws:
java.io.IOException- if an I/O error occurs.
XOutputFile
public XOutputFile(java.io.OutputStream out)
Creates an instance for the output stream.
XOutputFile
public XOutputFile()
Creates a in-memory byte array output stream where the contents can be retrieved by means of getByteArrayOutputStream() or getByteArray() methods.
Method Detail
close
public void close() throws java.io.IOExceptionClose stream and file- Throws:
java.io.IOException- if an I/O error occurs.
writeOEMStringVector
public void writeOEMStringVector(java.util.Vector<java.lang.String> v) throws java.io.IOExceptionConverts a vector of unicode strings to ASCII bytes and writes them to file using environment dependent line separator.- Throws:
java.io.IOException- if an I/O error occurs.
writeLine
public void writeLine(byte[] line) throws java.io.IOExceptionWrites an array of bytes to file and append line separator.- Throws:
java.io.IOException- if an I/O error occurs.
writeISOLine
public void writeISOLine(java.lang.String line) throws java.io.IOExceptionWrites a string as a line in a file encoded in ISO 8859-1 character set. The line is terminated with [CR]LF (Hex [0x0D] 0x0A) only in order to have the same character under Windows, Unix and EBCDIC environments.Typically, this function is used to write data that is then read with PhantomFile.readISOLine.
- Throws:
java.io.IOException- if an I/O error occurs.- See Also:
XFile.readISOLine()
writeBytes
public void writeBytes(byte[] d) throws java.io.IOExceptionWrite a byte array to the file.- Throws:
java.io.IOException- if an I/O error occurs.
writeBytes
public void writeBytes(byte[] d, int offset, int length) throws java.io.IOExceptionWrite a byte array to the file.- Throws:
java.io.IOException- if an I/O error occurs.
writeByte
public void writeByte(byte d) throws java.io.IOExceptionWrite a byte to the file.- Throws:
java.io.IOException- if an I/O error occurs.
writeByte
public void writeByte(int d) throws java.io.IOExceptionWrite a byte to the file.- Throws:
java.io.IOException- if an I/O error occurs.
writeOEMString
public void writeOEMString(java.lang.String s) throws java.io.IOExceptionWrites a string to its length using the OEM (ASCII) character set.- Throws:
java.io.IOException- if an I/O error occurs.
writeOEMString
public void writeOEMString(java.lang.String s, int length, byte pad) throws java.io.IOExceptionWrites a string padded to the specified length with the padding character. If the string is longer than the specified length, it will be truncated.- Throws:
java.io.IOException- if an I/O error occurs.
writeOEMString
public void writeOEMString(java.lang.String s, int length, int pad) throws java.io.IOExceptionWrites a string padded to the specified length with the padding character. If the string is longer than the specified length, it will be truncated.- Throws:
java.io.IOException- if an I/O error occurs.
writeString
public void writeString(java.lang.String s, int length, byte pad) throws java.io.IOExceptionWrites a string padded to the specified length with the padding character. If the string is longer than the specified length, it will be truncated.- Throws:
java.io.IOException- if an I/O error occurs.
writeString
public void writeString(java.lang.String s, int length, int pad) throws java.io.IOExceptionWrites a string padded to the specified length with the padding character. If the string is longer than the specified length, it will be truncated.- Throws:
java.io.IOException- if an I/O error occurs.
writeUnicodeString
public void writeUnicodeString(java.lang.String s) throws java.io.IOExceptionWrites a string to its length in Unicode.- Throws:
java.io.IOException- if an I/O error occurs.
writeZeroTermUnicodeString
public void writeZeroTermUnicodeString(java.lang.String s) throws java.io.IOExceptionWrites a zero-terminated Unicode string, if the string contains a zero-termination character, it will end there.- Throws:
java.io.IOException- if an I/O error occurs.
writeUnicodeString
public void writeUnicodeString(java.lang.String s, int length, char pad) throws java.io.IOExceptionWrites a string padded to the specified length with the padding character. If the string is longer than the specified length, it will be truncated.- Throws:
java.io.IOException- if an I/O error occurs.
writeIntelLong
public void writeIntelLong(int v) throws java.io.IOExceptionWrites an Intel formatted Long (32 bit value). It doesn't matter if it's a ULong or Long (signed value), because the 32 bit implementation will always treat it as signed.- Throws:
java.io.IOException- if an I/O error occurs.
writeIntelShort
public void writeIntelShort(int v) throws java.io.IOExceptionWrites an Intel formatted Short (16 bit signed value).- Throws:
java.io.IOException- if an I/O error occurs.
writeIntelUShort
public void writeIntelUShort(int v) throws java.io.IOExceptionWrites an Intel formatted UShort (16 bit unsigned value).- Throws:
java.io.IOException- if an I/O error occurs.
getDataOutputStream
public java.io.DataOutputStream getDataOutputStream()
Gets the data output stream instance.
getFileOutputStream
public java.io.FileOutputStream getFileOutputStream()
Gets the file output stream instance. This method returns null when the XOutputFile is an in-memory byte array output stream.
getByteArrayOutputStream
public java.io.ByteArrayOutputStream getByteArrayOutputStream()
Gets the byte array output stream instance. This method returns null when the XOutputFile is not an in-memory byte array output stream, but rather an output file.
getOutputStream
public java.io.OutputStream getOutputStream()
Gets the file output stream instance.
getByteArray
public byte[] getByteArray()
Gets the written data as a byte array when the file refers to an in-memory file. Otherwise null is returned.