Top Description Inners Fields Constructors Methods
org.hsqldb.lib

public Class FileUtil

extends Object
implements FileAccess
Class Inheritance
All Implemented Interfaces
org.hsqldb.lib.FileAccess
Imports
java.io.File, .FileDescriptor, .FileInputStream, .FileOutputStream, .FilenameFilter, .IOException, .InputStream, .OutputStream, java.util.Random, org.hsqldb.lib.java.JavaSystem

A collection of file management methods.

Also provides the default FileAccess implementation

Authors
Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net), Ocke Janssen [email protected]
Since
1.7.2
Version
2.7.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
public static class

Field Summary

Modifier and TypeField and Description
pack-priv static int
private static FileAccessRes
private static FileUtil
public final boolean
public final boolean
pack-priv final Random

Constructor Summary

AccessConstructor and Description
pack-priv
FileUtil()

Creates a new instance of FileUtil

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the absolute path
absolutePath
(String
the path for which to retrieve the absolute path
path
)

Retrieves the absolute path, given some path specification.

public File

Returns:

the canonical File
canonicalFile
(File
the File for which to retrieve the absolute File
f
)

Retrieves the canonical file for the given file, in a JDK 1.1 compliant way.

public File

Returns:

the canonical File
canonicalFile
(String
the path for which to retrieve the canonical File
path
)

Retrieves the canonical file for the given path, in a JDK 1.1 compliant way.

public String

Returns:

the canonical or absolute path
canonicalOrAbsolutePath
(String
the path for which to retrieve the canonical or absolute path
path
)

Retrieves the canonical path for the given path, or the absolute path if attempting to retrieve the canonical path fails.

public String

Returns:

the canonical path
canonicalPath
(File
the File for which to retrieve the canonical path
f
)

Retrieves the canonical path for the given File, in a JDK 1.1 compliant way.

public String

Returns:

the canonical path
canonicalPath
(String
the path for which to retrieve the canonical path
path
)

Retrieves the canonical path for the given path, in a JDK 1.1 compliant way.

public void
public boolean

Returns:

true if deleted
delete
(String
String
filename
)

Delete the named file

public void
deleteOnExit(File
the abstract pathname of the file be deleted when the virtual machine terminates
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.

public static boolean

Returns:

currently always true
deleteOrRenameDatabaseFiles
(String
full path or name of database (without a file extension)
dbNamePath
)

Utility method for user applications.

public boolean

Returns:

true if exists
exists
(String
String
filename
)

Return true or false based on whether the named file exists.

public boolean
exists(String fileName, boolean resource, Class<T> cla)

public static File[]

Returns:

File[]
getDatabaseFileList
(String
full path or name of database (without a file extension)
dbNamePath
)

Utility method for user applications.

public static File[]

Returns:

File[]
getDatabaseMainFileList
(String
full path or name of database (without a file extension)
dbNamePath
)

Returns a list of existing main files for a database.

public static FileAccess
getFileAccess(boolean isResource)

public FileAccess.FileSync
public static FileUtil
public boolean
public static String
public void
public static String
public InputStream
public OutputStream
public OutputStream
public boolean
public boolean
public boolean
private boolean

Returns:

true if successful
renameWithOverwrite
(String
String
oldname
,
String
String
newname
)

Rename the file with oldname to newname.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

discardSuffixLengthback to summary
pack-priv static int discardSuffixLength
fileAccessResback to summary
private static FileAccessRes fileAccessRes
fileUtilback to summary
private static FileUtil fileUtil
fsIsIgnoreCaseback to summary
public final boolean fsIsIgnoreCase
fsNormalizesPosixSeparatorback to summary
public final boolean fsNormalizesPosixSeparator
randomback to summary
pack-priv final Random random

Constructor Detail

FileUtilback to summary
pack-priv FileUtil()

Creates a new instance of FileUtil

Method Detail

absolutePathback to summary
public String absolutePath(String path)

Retrieves the absolute path, given some path specification.

Parameters
path:String

the path for which to retrieve the absolute path

Returns:String

the absolute path

canonicalFileback to summary
public File canonicalFile(File f) throws IOException

Retrieves the canonical file for the given file, in a JDK 1.1 compliant way.

Parameters
f:File

the File for which to retrieve the absolute File

Returns:File

the canonical File

Exceptions
IOException:
on error
canonicalFileback to summary
public File canonicalFile(String path) throws IOException

Retrieves the canonical file for the given path, in a JDK 1.1 compliant way.

Parameters
path:String

the path for which to retrieve the canonical File

Returns:File

the canonical File

Exceptions
IOException:
on error
canonicalOrAbsolutePathback to summary
public String canonicalOrAbsolutePath(String path)

Retrieves the canonical path for the given path, or the absolute path if attempting to retrieve the canonical path fails.

Parameters
path:String

the path for which to retrieve the canonical or absolute path

Returns:String

the canonical or absolute path

canonicalPathback to summary
public String canonicalPath(File f) throws IOException

Retrieves the canonical path for the given File, in a JDK 1.1 compliant way.

Parameters
f:File

the File for which to retrieve the canonical path

Returns:String

the canonical path

Exceptions
IOException:
on error
canonicalPathback to summary
public String canonicalPath(String path) throws IOException

Retrieves the canonical path for the given path, in a JDK 1.1 compliant way.

Parameters
path:String

the path for which to retrieve the canonical path

Returns:String

the canonical path

Exceptions
IOException:
on error
createParentDirsback to summary
public void createParentDirs(String filename)

Implements org.hsqldb.lib.FileAccess.createParentDirs.

deleteback to summary
public boolean delete(String filename)

Delete the named file

Parameters
filename:String

String

Returns:boolean

true if deleted

deleteOnExitback to summary
public void deleteOnExit(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:File

the abstract pathname of the file be deleted when the virtual machine terminates

deleteOrRenameDatabaseFilesback to summary
public static boolean deleteOrRenameDatabaseFiles(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:String

full path or name of database (without a file extension)

Returns:boolean

currently always true

existsback to summary
public boolean exists(String filename)

Return true or false based on whether the named file exists.

Parameters
filename:String

String

Returns:boolean

true if exists

existsback to summary
public boolean exists(String fileName, boolean resource, Class<T> cla)
getDatabaseFileListback to summary
public static File[] getDatabaseFileList(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:String

full path or name of database (without a file extension)

Returns:File[]

File[]

getDatabaseMainFileListback to summary
public static File[] getDatabaseMainFileList(String dbNamePath)

Returns a list of existing main files for a database. The list excludes non-essential files.

Parameters
dbNamePath:String

full path or name of database (without a file extension)

Returns:File[]

File[]

getFileAccessback to summary
public static FileAccess getFileAccess(boolean isResource)
getFileSyncback to summary
public FileAccess.FileSync getFileSync(OutputStream os) throws IOException

Implements org.hsqldb.lib.FileAccess.getFileSync.

getFileUtilback to summary
public static FileUtil getFileUtil()
isStreamElementback to summary
public boolean isStreamElement(String elementName)

Implements org.hsqldb.lib.FileAccess.isStreamElement.

makeDirectoriesback to summary
public static String makeDirectories(String path)
makeParentDirectoriesback to summary
public void makeParentDirectories(File f)
newDiscardFileNameback to summary
public static String newDiscardFileName(String filename)
openInputStreamElementback to summary
public InputStream openInputStreamElement(String streamName) throws IOException

Implements org.hsqldb.lib.FileAccess.openInputStreamElement.

openOutputStreamElementback to summary
public OutputStream openOutputStreamElement(String streamName) throws IOException

Implements org.hsqldb.lib.FileAccess.openOutputStreamElement.

openOutputStreamElementAppendback to summary
public OutputStream openOutputStreamElementAppend(String streamName) throws IOException

Implements org.hsqldb.lib.FileAccess.openOutputStreamElementAppend.

removeElementback to summary
public boolean removeElement(String filename)

Implements org.hsqldb.lib.FileAccess.removeElement.

renameElementback to summary
public boolean renameElement(String oldName, String newName)

Implements org.hsqldb.lib.FileAccess.renameElement.

renameElementOrCopyback to summary
public boolean renameElementOrCopy(String oldName, String newName, EventLogInterface logger)

Implements org.hsqldb.lib.FileAccess.renameElementOrCopy.

renameWithOverwriteback to summary
private boolean renameWithOverwrite(String oldname, String newname)

Rename the file with oldname to newname. If a file with newname already exists, it is deleted before the renaming operation proceeds.

If a file with oldname does not exist, no file will exist after the operation.

Parameters
oldname:String

String

newname:String

String

Returns:boolean

true if successful

org.hsqldb.lib back to summary

pack-priv Class FileUtil.DatabaseFilenameFilter

extends Object
implements FilenameFilter
Class Inheritance
All Implemented Interfaces
java.io.FilenameFilter

Field Summary

Modifier and TypeField and Description
private File
private String
private boolean
pack-priv String[]
private File
pack-priv String[]

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
DatabaseFilenameFilter(String dbNamePath, boolean extras)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if an accepted file
accept
(File
the directory
dir
,
String
file name
name
)

Implements java.io.FilenameFilter.accept.

Accepts all HSQLDB main persistence files as well as ".new" and ".old" versions.

public File[]
public File[]
public File[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canonicalFileback to summary
private File canonicalFile
dbNameback to summary
private String dbName
extraFilesback to summary
private boolean extraFiles
extraSuffixesback to summary
pack-priv String[] extraSuffixes
parentback to summary
private File parent
suffixesback to summary
pack-priv String[] suffixes

Constructor Detail

DatabaseFilenameFilterback to summary
pack-priv DatabaseFilenameFilter(String dbNamePath)
DatabaseFilenameFilterback to summary
pack-priv DatabaseFilenameFilter(String dbNamePath, boolean extras)

Method Detail

acceptback to summary
public boolean accept(File dir, String name)

Implements java.io.FilenameFilter.accept.

Accepts all HSQLDB main persistence files as well as ".new" and ".old" versions.

Parameters
dir:File

the directory

name:String

file name

Returns:boolean

true if an accepted file

getCompleteMainFileSetListback to summary
public File[] getCompleteMainFileSetList()
getExistingFileListInDirectoryback to summary
public File[] getExistingFileListInDirectory()
getExistingMainFileSetListback to summary
public File[] getExistingMainFileSetList()
org.hsqldb.lib back to summary

public Class FileUtil.FileSync

extends Object
implements FileSync
Class Inheritance
All Implemented Interfaces
org.hsqldb.lib.FileAccess.FileSync

Field Summary

Modifier and TypeField and Description
pack-priv FileDescriptor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

outDescriptorback to summary
pack-priv FileDescriptor outDescriptor

Constructor Detail

FileSyncback to summary
pack-priv FileSync(FileOutputStream os) throws IOException

Method Detail

syncback to summary
public void sync() throws IOException

Implements org.hsqldb.lib.FileAccess.FileSync.sync.