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 Link icon

    • newLine Link icon

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

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

    • XOutputFile Link icon

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

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

      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 Link icon

      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 Link icon

      public XOutputFile(OutputStream out)
      Creates an instance for the output stream.
    • XOutputFile Link icon

      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 Link icon

    • close Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

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

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      public OutputStream getOutputStream()
      Gets the file output stream instance.
    • getByteArray Link icon

      public byte[] getByteArray()
      Gets the written data as a byte array when the file refers to an in-memory file. Otherwise null is returned.