jhplot
Class IO
- java.lang.Object
-
- jhplot.IO
-
public class IO extends java.lang.Object
Methods used for input-output serialization of Java objects. Includes write (read) for the standard serialization. Objects can be compressed on-fly using GZip. Also, one can use XML format for serialization (writeXML(), readXML()). XML serialization is based on XSream and not compressed. Files can be read from URL. This package is equivalent to jhplot.io.Serialized() used in jHepWork.This utility also helps to work with files. You can use it to extract files and directories of a standard zip file to a destination directory, make list of files etc.
-
-
Constructor Summary
Constructors Constructor and Description IO()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
doc()
Show online documentation.static java.lang.Object
fromXML(java.lang.String xml)
Get object to XML using XSream packagestatic java.util.ArrayList
getFileList(java.lang.String dir, java.lang.String m)
Get list of files in all directories (including subdirectories).static java.lang.Object
read(java.io.File file, boolean compressed)
Read an object from a serialized filestatic java.lang.Object
read(java.lang.String name)
Read an object from a serialized file.static java.lang.Object
read(java.net.URL url, boolean compressed)
Read an object from an URLstatic java.lang.Object
readXML(java.lang.String name)
Read an object from a serialized XML file (should be written using writeXML() method).static java.lang.String
toXML(java.lang.Object ob)
Convert object to XML using XSream packagestatic java.lang.String
unzip(java.lang.String zipFilePath)
Extracts a zip file specified by the zipFilePath to the curent directory.static java.lang.String
unzip(java.lang.String zipFilePath, java.lang.String destDirectory)
Extracts a zip file specified by the zipFilePath to a directory specified by destDirectory (will be created if does not exists)static int
write(java.lang.Object o, java.lang.String name)
Write an object to a serialized file.static int
write(java.lang.Object o, java.lang.String name, boolean compressed)
Write an object to a serialized file.static int
writeXML(java.lang.Object o, java.lang.String name)
Write an object to a serialized XML file.
-
-
-
Method Detail
-
unzip
public static java.lang.String unzip(java.lang.String zipFilePath, java.lang.String destDirectory) throws java.io.IOException
Extracts a zip file specified by the zipFilePath to a directory specified by destDirectory (will be created if does not exists)- Parameters:
zipFilePath
- input zip filedestDirectory
- output directory- Throws:
java.io.IOException
-
unzip
public static java.lang.String unzip(java.lang.String zipFilePath) throws java.io.IOException
Extracts a zip file specified by the zipFilePath to the curent directory.- Parameters:
zipFilePath
- input zip file- Throws:
java.io.IOException
-
write
public static int write(java.lang.Object o, java.lang.String name, boolean compressed)
Write an object to a serialized file. Use the method read() to read it back.- Parameters:
o
- object to serialize into a filename
- serialized file name for output.compression
- set true if file should be compressed.- Returns:
- zero if no errors
-
write
public static int write(java.lang.Object o, java.lang.String name)
Write an object to a serialized file. Use the method read() to read it back. File will be compressed.- Parameters:
o
- object to serialize into a filename
- serialized file name for output.- Returns:
- zero if no errors
-
writeXML
public static int writeXML(java.lang.Object o, java.lang.String name)
Write an object to a serialized XML file. Use the method readXML() to get it back.- Parameters:
o
- object to serialize into a filename
- serialized file name for the output.- Returns:
- zero if no errors
-
read
public static java.lang.Object read(java.io.File file, boolean compressed)
Read an object from a serialized file- Parameters:
file
- serialized file for input.compressed
- set true if file is compressed.- Returns:
- object
-
read
public static java.lang.Object read(java.net.URL url, boolean compressed)
Read an object from an URL- Parameters:
name
- serialized file name for input from URLcompressed
- set true if file is compressed.- Returns:
- object
-
read
public static java.lang.Object read(java.lang.String name)
Read an object from a serialized file. File is assumed to be compressed, i.e when it was saved using write(obj,name) method.- Parameters:
name
- serialized file name for input.- Returns:
- object
-
readXML
public static java.lang.Object readXML(java.lang.String name)
Read an object from a serialized XML file (should be written using writeXML() method).- Parameters:
name
- serialized XML file name for the input.- Returns:
- object
-
toXML
public static java.lang.String toXML(java.lang.Object ob)
Convert object to XML using XSream package- Parameters:
ob
-- Returns:
- XML string
-
fromXML
public static java.lang.Object fromXML(java.lang.String xml)
Get object to XML using XSream package- Parameters:
xml
- XML string- Returns:
- object
-
getFileList
public static java.util.ArrayList getFileList(java.lang.String dir, java.lang.String m)
Get list of files in all directories (including subdirectories).- Parameters:
input
- directorym
- a string for regular expression to find matches in file name
-
doc
public void doc()
Show online documentation.
-
-
DMelt 3.0 © DataMelt by jWork.ORG