Package com.iizix.util
Class XOutputFile
java.lang.Object
com.iizix.util.XOutputFile
This class is used for creating and writing to files that are stored using Phantom Hurricane in OEM ASCII or Ansi character set.
Field Summary
Modifier and TypeFieldDescriptionstatic final byte[]
The New Line separator bytes for ISO character encoding.static final String
The New Line separator.Constructor Summary
ConstructorDescriptionCreates a in-memory byte array output stream where the contents can be retrieved by means of getByteArrayOutputStream() or getByteArray() methods.XOutputFile
(File file) Creates the specified file for write.XOutputFile
(OutputStream out) Creates an instance for the output stream.XOutputFile
(String fileName) Creates the specified file for write.XOutputFile
(String fileName, XFile openFile) Creates the specified file for write.XOutputFile
(String fileName, String previousFile) Creates the specified file for write.Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close stream and filebyte[]
Gets the written data as a byte array when the file refers to an in-memory file.Gets the byte array output stream instance.Gets the data output stream instance.Gets the file output stream instance.Gets the file output stream instance.void
writeByte
(byte d) Write a byte to the file.void
writeByte
(int d) Write a byte to the file.void
writeBytes
(byte[] d) Write a byte array to the file.void
writeBytes
(byte[] d, int offset, int length) Write a byte array to the file.void
writeIntelLong
(int v) Writes an Intel formatted Long (32 bit value).void
writeIntelShort
(int v) Writes an Intel formatted Short (16 bit signed value).void
writeIntelUShort
(int v) Writes an Intel formatted UShort (16 bit unsigned value).void
writeISOLine
(String line) Writes a string as a line in a file encoded in ISO 8859-1 character set.void
writeLine
(byte[] line) Writes an array of bytes to file and append line separator.void
Writes a string to its length using the OEM (ASCII) character set.void
writeOEMString
(String s, int length, byte pad) Writes a string padded to the specified length with the padding character.void
writeOEMString
(String s, int length, int pad) Writes a string padded to the specified length with the padding character.void
Converts a vector of unicode strings to ASCII bytes and writes them to file using environment dependent line separator.void
writeString
(String s, int length, byte pad) Writes a string padded to the specified length with the padding character.void
writeString
(String s, int length, int pad) Writes a string padded to the specified length with the padding character.void
Writes a string to its length in Unicode.void
writeUnicodeString
(String s, int length, char pad) Writes a string padded to the specified length with the padding character.void
Writes a zero-terminated Unicode string, if the string contains a zero-termination character, it will end there.
Field Details
newLine
The New Line separator.isoNewLine
public static final byte[] isoNewLineThe New Line separator bytes for ISO character encoding.
Constructor Details
XOutputFile
Creates the specified file for write.- Throws:
IOException
- if an I/O error occurs.
XOutputFile
Creates the specified file for write.- Throws:
IOException
- if an I/O error occurs.
XOutputFile
Creates the specified file for write. The directory of the file name is taken from the instance of the PhantomFile passed into this method.- Throws:
IOException
- if an I/O error occurs.
XOutputFile
Creates the specified file for write. The directory of the file name is taken from the file name passed into this method.- Throws:
IOException
- if an I/O error occurs.
XOutputFile
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 Details
close
Close stream and file- Throws:
IOException
- if an I/O error occurs.
writeOEMStringVector
Converts a vector of unicode strings to ASCII bytes and writes them to file using environment dependent line separator.- Throws:
IOException
- if an I/O error occurs.
writeLine
Writes an array of bytes to file and append line separator.- Throws:
IOException
- if an I/O error occurs.
writeISOLine
Writes 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:
IOException
- if an I/O error occurs.- See Also:
writeBytes
Write a byte array to the file.- Throws:
IOException
- if an I/O error occurs.
writeBytes
Write a byte array to the file.- Throws:
IOException
- if an I/O error occurs.
writeByte
Write a byte to the file.- Throws:
IOException
- if an I/O error occurs.
writeByte
Write a byte to the file.- Throws:
IOException
- if an I/O error occurs.
writeOEMString
Writes a string to its length using the OEM (ASCII) character set.- Throws:
IOException
- if an I/O error occurs.
writeOEMString
Writes 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:
IOException
- if an I/O error occurs.
writeOEMString
Writes 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:
IOException
- if an I/O error occurs.
writeString
Writes 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:
IOException
- if an I/O error occurs.
writeString
Writes 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:
IOException
- if an I/O error occurs.
writeUnicodeString
Writes a string to its length in Unicode.- Throws:
IOException
- if an I/O error occurs.
writeZeroTermUnicodeString
Writes a zero-terminated Unicode string, if the string contains a zero-termination character, it will end there.- Throws:
IOException
- if an I/O error occurs.
writeUnicodeString
Writes 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:
IOException
- if an I/O error occurs.
writeIntelLong
Writes 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:
IOException
- if an I/O error occurs.
writeIntelShort
Writes an Intel formatted Short (16 bit signed value).- Throws:
IOException
- if an I/O error occurs.
writeIntelUShort
Writes an Intel formatted UShort (16 bit unsigned value).- Throws:
IOException
- if an I/O error occurs.
getDataOutputStream
Gets the data output stream instance.getFileOutputStream
Gets the file output stream instance. This method returns null when the XOutputFile is an in-memory byte array output stream.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
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.