public final class FileHandling
extends java.lang.Object
Constructor and Description |
---|
FileHandling() |
Modifier and Type | Method and Description |
---|---|
static void |
copyFile(java.lang.String source,
java.lang.String dest)
Copy a file byte by byte.
|
static java.lang.Object |
deSerialize(java.lang.String pathname)
Restores an object from a file.
|
static java.text.DecimalFormat |
getCounterFormat(int number)
Get a decimal format for integer counters.
|
static java.lang.String |
getFileExtension(java.io.File f)
Extracts the file extension from a java.io.File object.
|
static java.lang.String |
getFileExtension(java.lang.String filename)
Extracts the file extension from a String object.
|
static java.lang.String |
getFileSeparator()
Get the system dependent file separator.
|
static java.lang.String |
getJarDir()
Get the absolute path to the directory of this jar-archive.
|
static double[][] |
readArrayFromFile(java.lang.String pathname)
Reads whitespace delimited table data from an ascii or unicode file.
|
static java.lang.String |
readTextFile(java.lang.String pathname)
Reads a file.
|
static void |
serialize(java.lang.String pathname,
java.lang.Object obj)
Serializes an object to a file.
|
static java.lang.String |
stripExtension(java.lang.String path)
Removes the characters after the last occurence of a "." in path
inclusive the ".".
|
static java.lang.String |
stripFilename(java.io.File f)
Get the body of a filename.
|
static java.lang.String |
stripFilename(java.lang.String path)
Get the body of a filename.
|
static void |
writeArrayToFile(double[][] array,
java.lang.String pathname,
java.text.DecimalFormat df,
java.lang.String header)
Writes an array whitespace delimited to a file.
|
static void |
writeArrayToFile(int[] array,
java.lang.String pathname,
java.text.DecimalFormat df)
Writes an array whitespace delimited to a file.
|
static void |
writeTextFile(java.lang.String pathname,
java.lang.String s)
Writes a file.
|
public static void serialize(java.lang.String pathname, java.lang.Object obj) throws java.io.IOException
pathname
- Pathname for saving the object.obj
- Any object.java.io.IOException
- In case the file can not be written.public static java.lang.Object deSerialize(java.lang.String pathname) throws java.io.IOException, java.io.FileNotFoundException, java.lang.ClassNotFoundException
pathname
- Pathname of the object.java.io.IOException
- In case the file can not be read.java.io.FileNotFoundException
- In case the file could not be found.java.lang.ClassNotFoundException
- In case the object can not be de-serialized. This can happen
after updates or when the file was edited elsewhere.public static java.text.DecimalFormat getCounterFormat(int number)
number
- The maximum value of your enumeration.public static java.lang.String getFileExtension(java.io.File f)
f
- The java.io.File object.public static java.lang.String getFileExtension(java.lang.String filename)
filename
- The java.io.File object.public static java.lang.String stripFilename(java.io.File f)
f
- The file.public static java.lang.String stripExtension(java.lang.String path)
path
- A string representing a complete file name inclusive filename
extension.public static java.lang.String stripFilename(java.lang.String path)
path
- The complete filename.public static void writeArrayToFile(double[][] array, java.lang.String pathname, java.text.DecimalFormat df, java.lang.String header) throws java.io.IOException
array
- A two dimensional array.pathname
- The full pathname of a destination file.df
- A DecimalFormat for formatting the output.header
- A file header.java.io.IOException
- In case the file can not be created.public static void writeArrayToFile(int[] array, java.lang.String pathname, java.text.DecimalFormat df) throws java.io.IOException
array
- A two dimensional array.pathname
- The full pathname of a destination file.df
- A DecimalFormat for formatting the output.java.io.IOException
- in case the file can not be created.public static double[][] readArrayFromFile(java.lang.String pathname) throws java.io.IOException
pathname
- The absolute path of a file containing a whitespace delimited
table.java.io.IOException
- in case no file can be created from pathname
public static java.lang.String readTextFile(java.lang.String pathname)
pathname
- The absolute pathname of the file.public static void writeTextFile(java.lang.String pathname, java.lang.String s) throws java.io.IOException
pathname
- The absolute pathname of the file.s
- The string to be written.java.io.IOException
- In case the file can not be written.public static void copyFile(java.lang.String source, java.lang.String dest)
source
- Complete path of the source file.dest
- Complete path of the destination file.public static java.lang.String getFileSeparator()
public static java.lang.String getJarDir()