Documentation of 'jhplot.io.HFileXML' Java class.
HFileXML
jhplot.io

Class HFileXML



  • public class HFileXML
    extends java.lang.Object
    Open a XML file to write/read objects in sequential order using java serialization in XML. Do not forget apply close() at the end of run.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      java.io.FileOutputStream oof 
      java.io.ObjectOutputStream oos 
      java.io.File recordsFile 
    • Constructor Summary

      Constructors 
      Constructor and Description
      HFileXML(java.lang.String file)
      Open a XML file to read objects from a file.
      HFileXML(java.lang.String file, java.lang.String option)
      Open a XML file to write or read objects to/from a serialized file in sequential order.
      HFileXML(java.lang.String file, java.lang.String option, int bufferSize)
      Open a XML file to write or read objects to/from a serialized file in sequential order.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean close()
      Close the file
      void doc()
      Show online documentation.
      int getBufferSize()
      Get current buffer size for I/O.
      int getEntries()
      Get number of processed entries
      java.util.Map<java.lang.String,java.lang.Object> getObjectMap()
      Return objects stored in the form of a map.
      java.lang.Object read()
      Get object from a file.
      java.lang.Object read(java.lang.String key)
      Read an object using a key if exits.
      boolean write(java.lang.Object ob)
      Add an object to a XML file
      boolean write(java.lang.String key, java.lang.Object ob)
      Add an object using a key.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • recordsFile

        public java.io.File recordsFile
      • oof

        public java.io.FileOutputStream oof
      • oos

        public java.io.ObjectOutputStream oos
    • Constructor Detail

      • HFileXML

        public HFileXML(java.lang.String file,
                        java.lang.String option,
                        int bufferSize)
        Open a XML file to write or read objects to/from a serialized file in sequential order. If "w" option is set, the old file will be removed. Use close() to flash the buffer and close the file. You can set buffer size for I/O . Make it larger for a heavy I/O. It is best to use buffer sizes that are multiples of 1024 bytes. That works best with most built-in buffering in hard disks.

        File extension is *.jxml

        You can also insert objects using the keys and read them back. In this case, avoid writing many objects without the keys since the extraction of keys will be very inefficient. Try not mix write/read with keys or without.

        Parameters:
        file - File name
        option - Option to create the file . If "w" - write a file (or read) file, if "r" only read created file.
        bufferSize - set buffer size for I/O. It is best to use buffer sizes that are multiples of 1024 bytes.
      • HFileXML

        public HFileXML(java.lang.String file,
                        java.lang.String option)
        Open a XML file to write or read objects to/from a serialized file in sequential order. If "w" option is set, the old file will be removed. The default buffer size is set to 12k.
        Parameters:
        file - File name
        option - Option to create the file . If "w" - write a file (or read) file, if "r" only read created file.
      • HFileXML

        public HFileXML(java.lang.String file)
        Open a XML file to read objects from a file.
        Parameters:
        file - File name for reading
    • Method Detail

      • write

        public boolean write(java.lang.String key,
                             java.lang.Object ob)
        Add an object using a key.
        Parameters:
        key - key to access the object.
        ob - object to be inserted.
        Returns:
        false if the key exits.
      • getObjectMap

        public java.util.Map<java.lang.String,java.lang.Object> getObjectMap()
        Return objects stored in the form of a map.
        Returns:
      • getBufferSize

        public int getBufferSize()
        Get current buffer size for I/O.
      • write

        public boolean write(java.lang.Object ob)
        Add an object to a XML file
        Parameters:
        ob - Object
        Returns:
        true if success
      • read

        public java.lang.Object read()
        Get object from a file. Returns Null if the end of file reached.
        Returns:
        Object object or Null.
      • read

        public java.lang.Object read(java.lang.String key)
        Read an object using a key if exits.
        Parameters:
        key -
        Returns:
        returned object.
      • close

        public boolean close()
        Close the file
        Returns:
      • getEntries

        public int getEntries()
        Get number of processed entries
        Returns:
        No of entries
      • doc

        public void doc()
        Show online documentation.

DMelt 3.0 © DataMelt by jWork.ORG