Class XOutputFile

java.lang.Object
com.iizix.util.XOutputFile

public class XOutputFile extends Object
This class is used for creating and writing to files that are stored using Phantom Hurricane in OEM ASCII or Ansi character set.
  • Field Details

    • newLine

      public static final String newLine
      The New Line separator.
    • isoNewLine

      public static final byte[] isoNewLine
      The New Line separator bytes for ISO character encoding.
  • Constructor Details

    • XOutputFile

      public XOutputFile(File file) throws IOException
      Creates the specified file for write.
      Throws:
      IOException - if an I/O error occurs.
    • XOutputFile

      public XOutputFile(String fileName) throws IOException
      Creates the specified file for write.
      Throws:
      IOException - if an I/O error occurs.
    • XOutputFile

      public XOutputFile(String fileName, XFile openFile) throws IOException
      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

      public XOutputFile(String fileName, String previousFile) throws IOException
      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

      public XOutputFile(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 Details

    • close

      public void close() throws IOException
      Close stream and file
      Throws:
      IOException - if an I/O error occurs.
    • writeOEMStringVector

      public void writeOEMStringVector(Vector<String> v) throws IOException
      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

      public void writeLine(byte[] line) throws IOException
      Writes an array of bytes to file and append line separator.
      Throws:
      IOException - if an I/O error occurs.
    • writeISOLine

      public void writeISOLine(String line) throws IOException
      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

      public void writeBytes(byte[] d) throws IOException
      Write a byte array to the file.
      Throws:
      IOException - if an I/O error occurs.
    • writeBytes

      public void writeBytes(byte[] d, int offset, int length) throws IOException
      Write a byte array to the file.
      Throws:
      IOException - if an I/O error occurs.
    • writeByte

      public void writeByte(byte d) throws IOException
      Write a byte to the file.
      Throws:
      IOException - if an I/O error occurs.
    • writeByte

      public void writeByte(int d) throws IOException
      Write a byte to the file.
      Throws:
      IOException - if an I/O error occurs.
    • writeOEMString

      public void writeOEMString(String s) throws IOException
      Writes a string to its length using the OEM (ASCII) character set.
      Throws:
      IOException - if an I/O error occurs.
    • writeOEMString

      public void writeOEMString(String s, int length, byte pad) throws IOException
      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

      public void writeOEMString(String s, int length, int pad) throws IOException
      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

      public void writeString(String s, int length, byte pad) throws IOException
      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

      public void writeString(String s, int length, int pad) throws IOException
      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

      public void writeUnicodeString(String s) throws IOException
      Writes a string to its length in Unicode.
      Throws:
      IOException - if an I/O error occurs.
    • writeZeroTermUnicodeString

      public void writeZeroTermUnicodeString(String s) throws IOException
      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

      public void writeUnicodeString(String s, int length, char pad) throws IOException
      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

      public void writeIntelLong(int v) throws IOException
      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

      public void writeIntelShort(int v) throws IOException
      Writes an Intel formatted Short (16 bit signed value).
      Throws:
      IOException - if an I/O error occurs.
    • writeIntelUShort

      public void writeIntelUShort(int v) throws IOException
      Writes an Intel formatted UShort (16 bit unsigned value).
      Throws:
      IOException - if an I/O error occurs.
    • getDataOutputStream

      public DataOutputStream getDataOutputStream()
      Gets the data output stream instance.
    • getFileOutputStream

      public 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 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 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.