public class IOUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
TSMODE_IGNORE_TSERRORS |
static int |
TSMODE_NORMAL |
static int |
TSMODE_UPDATE_SOURCE |
Constructor and Description |
---|
IOUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
copyFile(java.io.File source,
java.io.File target,
int tsMode)
Copies a file and sets the file timestamp
|
static java.lang.String |
getAbsolutePath(java.io.File f)
Returns the absolute path of a File and makes sure that directory
paths always end with a /
|
static void |
getFilesAndDirs(java.io.File startDir,
taVector v,
boolean getFiles,
boolean getDirs,
boolean getAllTree)
Gets a sorted list of files and directories.
|
static java.lang.Throwable |
getLastError()
Gets the last error.
|
static java.lang.String |
getVersion()
Returns the version of the class.
|
static java.lang.String |
readTextFile(java.lang.String filename,
java.lang.String encoding)
Reads a text file fully.
|
static boolean |
writeTextFile(java.lang.String filename,
java.lang.String text,
java.lang.String encoding)
Calls writeTextFile(filename, text, encoding, eol) where eol is \r\n for
Windows systems or \n for all other systems
|
static boolean |
writeTextFile(java.lang.String filename,
java.lang.String text,
java.lang.String encoding,
java.lang.String eol)
Writes a text file fully (adds a newline at the end when none there)
|
public static final int TSMODE_NORMAL
public static final int TSMODE_UPDATE_SOURCE
public static final int TSMODE_IGNORE_TSERRORS
public static boolean copyFile(java.io.File source, java.io.File target, int tsMode)
source
- source Filetarget
- target FiletsMode
- timestamp mode, ORed value of TSMODE_XXXpublic static java.lang.String getAbsolutePath(java.io.File f)
f
- The file oe directorypublic static void getFilesAndDirs(java.io.File startDir, taVector v, boolean getFiles, boolean getDirs, boolean getAllTree)
startDir
- The start directoryv
- The taVector for storing the list of File. Must not be null.getFiles
- If true, files are returnedgetDirs
- If true, directories are returnedgetAllTree
- If true, the whole tree is walkedpublic static java.lang.Throwable getLastError()
public static java.lang.String getVersion()
public static java.lang.String readTextFile(java.lang.String filename, java.lang.String encoding)
filename
- The path of the fileencoding
- The encoding to use. If null, UTF-8 is used.public static boolean writeTextFile(java.lang.String filename, java.lang.String text, java.lang.String encoding)
filename
- The path of the file. Existing files are overwritten!text
- The text to writeencoding
- The encoding to use. If null, UTF-8 is used.public static boolean writeTextFile(java.lang.String filename, java.lang.String text, java.lang.String encoding, java.lang.String eol)
filename
- The path of the file. Existing files are overwritten!text
- The text to writeencoding
- The encoding to use. If null, UTF-8 is used.eol
- The string to use for end-of-line
Use "\r\n" for Windows, "\n" for Linux and Max >= OSX and "\r" for Mac < OSX