|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.util.FileUtils
public class FileUtils
This utility class supports basic operations on files
Method Summary | |
---|---|
static void |
createDirs(java.lang.String fileName)
Create all required directories that are required for this file. |
static java.lang.String |
createTempFile(java.lang.String prefix,
java.lang.String suffix,
boolean deleteOnExit,
boolean inTempDir)
Create a new temporary file. |
static void |
delete(java.lang.String fileName)
Delete a file. |
static boolean |
exists(java.lang.String fileName)
Checks if a file exists. |
static boolean |
fileStartsWith(java.lang.String fileName,
java.lang.String prefix)
Check if a file starts with a given prefix. |
static java.lang.String |
getAbsolutePath(java.lang.String fileName)
Get the absolute file name. |
static java.lang.String |
getFileInUserHome(java.lang.String fileName)
Get the absolute file path of a file in the user home directory. |
static java.lang.String |
getFileName(java.lang.String name)
Get the file name (without directory part). |
static long |
getLastModified(java.lang.String fileName)
Get the last modified date of a file. |
static java.lang.String |
getParent(java.lang.String fileName)
Get the parent directory of a file or directory. |
static boolean |
isAbsolute(java.lang.String fileName)
Check if the file name includes a path. |
static boolean |
isDirectory(java.lang.String fileName)
Check if it is a file or a directory. |
static boolean |
isReadOnly(java.lang.String fileName)
Check if a file is read-only. |
static long |
length(java.lang.String fileName)
Get the length of a file. |
static java.lang.String[] |
listFiles(java.lang.String path)
List the files in the given directory. |
static void |
mkdirs(java.io.File directory)
Create the directory and all parent directories if required. |
static java.lang.String |
normalize(java.lang.String fileName)
Normalize a file name. |
static java.io.InputStream |
openFileInputStream(java.lang.String fileName)
Create an input stream to read from the file. |
static java.io.OutputStream |
openFileOutputStream(java.lang.String fileName,
boolean append)
Create an output stream to write into the file. |
static void |
rename(java.lang.String oldName,
java.lang.String newName)
Rename a file if this is allowed. |
static void |
setLength(java.io.RandomAccessFile file,
long newLength)
Change the length of the file. |
static void |
setLength(java.lang.String fileName,
long length)
Set the file length. |
static boolean |
tryDelete(java.lang.String fileName)
Try to delete a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void mkdirs(java.io.File directory) throws java.io.IOException
directory
- the directory
java.io.IOException
public static void setLength(java.io.RandomAccessFile file, long newLength) throws java.io.IOException
file
- the random access filenewLength
- the new length
java.io.IOException
public static java.lang.String getFileInUserHome(java.lang.String fileName)
fileName
- the file name
public static java.lang.String getFileName(java.lang.String name) throws java.sql.SQLException
name
- the directory and file name
java.sql.SQLException
public static java.lang.String normalize(java.lang.String fileName) throws java.sql.SQLException
fileName
- the file name
java.sql.SQLException
public static boolean tryDelete(java.lang.String fileName)
fileName
- the file name
public static boolean isReadOnly(java.lang.String fileName)
fileName
- the file name
public static boolean exists(java.lang.String fileName)
fileName
- the file name
public static long length(java.lang.String fileName)
fileName
- the file name
public static java.lang.String createTempFile(java.lang.String prefix, java.lang.String suffix, boolean deleteOnExit, boolean inTempDir) throws java.io.IOException
prefix
- the prefix of the file name (including directory name if
required)suffix
- the suffixdeleteOnExit
- if the file should be deleted when the virtual
machine existsinTempDir
- if the file should be stored in the temporary directory
java.io.IOException
public static java.lang.String getParent(java.lang.String fileName)
fileName
- the file or directory name
public static java.lang.String[] listFiles(java.lang.String path) throws java.sql.SQLException
path
- the directory
java.sql.SQLException
public static boolean isDirectory(java.lang.String fileName)
fileName
- the file or directory name
public static boolean isAbsolute(java.lang.String fileName)
fileName
- the file name
public static java.lang.String getAbsolutePath(java.lang.String fileName)
fileName
- the file name
public static boolean fileStartsWith(java.lang.String fileName, java.lang.String prefix)
fileName
- the complete file nameprefix
- the prefix
public static java.io.InputStream openFileInputStream(java.lang.String fileName) throws java.io.IOException
fileName
- the file name
java.io.IOException
public static java.io.OutputStream openFileOutputStream(java.lang.String fileName, boolean append) throws java.sql.SQLException
fileName
- the file nameappend
- if true, the file will grow, if false, the file will be
truncated first
java.sql.SQLException
public static void rename(java.lang.String oldName, java.lang.String newName) throws java.sql.SQLException
oldName
- the old fully qualified file namenewName
- the new fully qualified file name
java.sql.SQLException
public static void createDirs(java.lang.String fileName) throws java.sql.SQLException
fileName
- the file name (not directory name)
java.sql.SQLException
public static void delete(java.lang.String fileName) throws java.sql.SQLException
fileName
- the file name
java.sql.SQLException
public static long getLastModified(java.lang.String fileName)
fileName
- the file name
public static void setLength(java.lang.String fileName, long length) throws java.sql.SQLException
fileName
- the file namelength
- the new length
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |