- java.lang.Object
- 
- org.hsqldb.lib.FileUtil
 
- 
- All Implemented Interfaces:
- FileAccess
 
 public class FileUtil extends java.lang.Object implements FileAccess A collection of file management methods.Also provides the default FileAccess implementation - Since:
- 1.7.2
- Author:
- Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net), Ocke Janssen oj@openoffice.org
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classFileUtil.FileSync
 - 
Field SummaryFields Modifier and Type Field Description booleanfsIsIgnoreCasebooleanfsNormalizesPosixSeparator- 
Fields inherited from interface org.hsqldb.lib.FileAccessELEMENT_READ, ELEMENT_READWRITE, ELEMENT_SEEKABLEREAD, ELEMENT_TRUNCATE, ELEMENT_WRITE
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringabsolutePath(java.lang.String path)Retrieves the absolute path, given some path specification.java.io.FilecanonicalFile(java.io.File f)Retrieves the canonical file for the given file, in a JDK 1.1 compliant way.java.io.FilecanonicalFile(java.lang.String path)Retrieves the canonical file for the given path, in a JDK 1.1 compliant way.java.lang.StringcanonicalOrAbsolutePath(java.lang.String path)Retrieves the canonical path for the given path, or the absolute path if attempting to retrieve the canonical path fails.java.lang.StringcanonicalPath(java.io.File f)Retrieves the canonical path for the given File, in a JDK 1.1 compliant way.java.lang.StringcanonicalPath(java.lang.String path)Retrieves the canonical path for the given path, in a JDK 1.1 compliant way.voidcreateParentDirs(java.lang.String filename)booleandelete(java.lang.String filename)Delete the named filevoiddeleteOnExit(java.io.File f)Requests, in a JDK 1.1 compliant way, that the file or directory denoted by the given abstract pathname be deleted when the virtual machine terminates.static booleandeleteOrRenameDatabaseFiles(java.lang.String dbNamePath)Utility method for user applications.booleanexists(java.lang.String filename)Return true or false based on whether the named file exists.booleanexists(java.lang.String fileName, boolean resource, java.lang.Class cla)static java.io.File[]getDatabaseFileList(java.lang.String dbNamePath)Utility method for user applications.static java.io.File[]getDatabaseMainFileList(java.lang.String dbNamePath)Returns a list of existing main files for a database.static FileAccessgetFileAccess(boolean isResource)FileAccess.FileSyncgetFileSync(java.io.OutputStream os)static FileUtilgetFileUtil()booleanisStreamElement(java.lang.String elementName)static java.lang.StringmakeDirectories(java.lang.String path)voidmakeParentDirectories(java.io.File f)static java.lang.StringnewDiscardFileName(java.lang.String filename)java.io.InputStreamopenInputStreamElement(java.lang.String streamName)java.io.OutputStreamopenOutputStreamElement(java.lang.String streamName)java.io.OutputStreamopenOutputStreamElementAppend(java.lang.String streamName)booleanremoveElement(java.lang.String filename)booleanrenameElement(java.lang.String oldName, java.lang.String newName)booleanrenameElementOrCopy(java.lang.String oldName, java.lang.String newName, EventLogInterface logger)
 
- 
- 
- 
Method Detail- 
getFileUtilpublic static FileUtil getFileUtil() 
 - 
getFileAccesspublic static FileAccess getFileAccess(boolean isResource) 
 - 
isStreamElementpublic boolean isStreamElement(java.lang.String elementName) - Specified by:
- isStreamElementin interface- FileAccess
 
 - 
openInputStreamElementpublic java.io.InputStream openInputStreamElement(java.lang.String streamName) throws java.io.IOException- Specified by:
- openInputStreamElementin interface- FileAccess
- Throws:
- java.io.IOException
 
 - 
createParentDirspublic void createParentDirs(java.lang.String filename) - Specified by:
- createParentDirsin interface- FileAccess
 
 - 
removeElementpublic boolean removeElement(java.lang.String filename) - Specified by:
- removeElementin interface- FileAccess
 
 - 
renameElementpublic boolean renameElement(java.lang.String oldName, java.lang.String newName)- Specified by:
- renameElementin interface- FileAccess
 
 - 
renameElementOrCopypublic boolean renameElementOrCopy(java.lang.String oldName, java.lang.String newName, EventLogInterface logger)- Specified by:
- renameElementOrCopyin interface- FileAccess
 
 - 
openOutputStreamElementpublic java.io.OutputStream openOutputStreamElement(java.lang.String streamName) throws java.io.IOException- Specified by:
- openOutputStreamElementin interface- FileAccess
- Throws:
- java.io.IOException
 
 - 
openOutputStreamElementAppendpublic java.io.OutputStream openOutputStreamElementAppend(java.lang.String streamName) throws java.io.IOException- Specified by:
- openOutputStreamElementAppendin interface- FileAccess
- Throws:
- java.io.IOException
 
 - 
deletepublic boolean delete(java.lang.String filename) Delete the named file- Parameters:
- filename- String
- Returns:
- true if deleted
 
 - 
deleteOnExitpublic void deleteOnExit(java.io.File f) Requests, in a JDK 1.1 compliant way, that the file or directory denoted by the given abstract pathname be deleted when the virtual machine terminates.Deletion will be attempted only for JDK 1.2 and greater runtime environments and only upon normal termination of the virtual machine, as defined by the Java Language Specification. Once deletion has been sucessfully requested, it is not possible to cancel the request. This method should therefore be used with care. - Parameters:
- f- the abstract pathname of the file be deleted when the virtual machine terminates
 
 - 
existspublic boolean exists(java.lang.String filename) Return true or false based on whether the named file exists.- Parameters:
- filename- String
- Returns:
- true if exists
 
 - 
existspublic boolean exists(java.lang.String fileName, boolean resource, java.lang.Class cla)
 - 
absolutePathpublic java.lang.String absolutePath(java.lang.String path) Retrieves the absolute path, given some path specification.- Parameters:
- path- the path for which to retrieve the absolute path
- Returns:
- the absolute path
 
 - 
canonicalFilepublic java.io.File canonicalFile(java.io.File f) throws java.io.IOExceptionRetrieves the canonical file for the given file, in a JDK 1.1 compliant way.- Parameters:
- f- the File for which to retrieve the absolute File
- Returns:
- the canonical File
- Throws:
- java.io.IOException- on error
 
 - 
canonicalFilepublic java.io.File canonicalFile(java.lang.String path) throws java.io.IOExceptionRetrieves the canonical file for the given path, in a JDK 1.1 compliant way.- Parameters:
- path- the path for which to retrieve the canonical File
- Returns:
- the canonical File
- Throws:
- java.io.IOException- on error
 
 - 
canonicalPathpublic java.lang.String canonicalPath(java.io.File f) throws java.io.IOExceptionRetrieves the canonical path for the given File, in a JDK 1.1 compliant way.- Parameters:
- f- the File for which to retrieve the canonical path
- Returns:
- the canonical path
- Throws:
- java.io.IOException- on error
 
 - 
canonicalPathpublic java.lang.String canonicalPath(java.lang.String path) throws java.io.IOExceptionRetrieves the canonical path for the given path, in a JDK 1.1 compliant way.- Parameters:
- path- the path for which to retrieve the canonical path
- Returns:
- the canonical path
- Throws:
- java.io.IOException- on error
 
 - 
canonicalOrAbsolutePathpublic java.lang.String canonicalOrAbsolutePath(java.lang.String path) Retrieves the canonical path for the given path, or the absolute path if attempting to retrieve the canonical path fails.- Parameters:
- path- the path for which to retrieve the canonical or absolute path
- Returns:
- the canonical or absolute path
 
 - 
makeParentDirectoriespublic void makeParentDirectories(java.io.File f) 
 - 
makeDirectoriespublic static java.lang.String makeDirectories(java.lang.String path) 
 - 
getFileSyncpublic FileAccess.FileSync getFileSync(java.io.OutputStream os) throws java.io.IOException - Specified by:
- getFileSyncin interface- FileAccess
- Throws:
- java.io.IOException
 
 - 
deleteOrRenameDatabaseFilespublic static boolean deleteOrRenameDatabaseFiles(java.lang.String dbNamePath) Utility method for user applications. Attempts to delete all the files for the database as listed by the getDatabaseFileList() method. If any of the current, main database files cannot be deleted, it is renamed by adding a suffix containing a hexadecimal timestamp portion and the ".old" extension. Also deletes the ".tmp" directory.- Parameters:
- dbNamePath- full path or name of database (without a file extension)
- Returns:
- currently always true
 
 - 
getDatabaseFileListpublic static java.io.File[] getDatabaseFileList(java.lang.String dbNamePath) Utility method for user applications. Returns a list of files that currently exist for a database. The list includes current database files as well as ".new", and ".old" versions of the files, plus any app logs.- Parameters:
- dbNamePath- full path or name of database (without a file extension)
- Returns:
- File[]
 
 - 
getDatabaseMainFileListpublic static java.io.File[] getDatabaseMainFileList(java.lang.String dbNamePath) Returns a list of existing main files for a database. The list excludes non-essential files.- Parameters:
- dbNamePath- full path or name of database (without a file extension)
- Returns:
- File[]
 
 - 
newDiscardFileNamepublic static java.lang.String newDiscardFileName(java.lang.String filename) 
 
- 
 
-