本文整理汇总了Java中org.hsqldb.lib.FileUtil类的典型用法代码示例。如果您正苦于以下问题:Java FileUtil类的具体用法?Java FileUtil怎么用?Java FileUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileUtil类属于org.hsqldb.lib包,在下文中一共展示了FileUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initParams
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
protected void initParams(Database database, String fileSettingsString,
boolean defrag) {
this.database = database;
fa = FileUtil.getFileUtil();
textFileSettings = new TextFileSettings(database, fileSettingsString);
dataFileName = textFileSettings.getFileName();
if (dataFileName == null) {
throw Error.error(ErrorCode.X_S0501);
}
dataFileName = ((FileUtil) fa).canonicalOrAbsolutePath(dataFileName);
maxCacheRows = textFileSettings.getMaxCacheRows();
maxCacheBytes = textFileSettings.getMaxCacheBytes();
// max size is 256G
maxDataFileSize = (long) Integer.MAX_VALUE * Logger.largeDataFactor;
cachedRowPadding = 1;
dataFileScale = 1;
}
示例2: deleteFile
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
static void deleteFile(Database database, String fileName) {
FileAccess fileAccess = database.logger.getFileAccess();
// first attempt to delete
fileAccess.removeElement(fileName);
if (database.logger.isStoredFileAccess()) {
return;
}
if (fileAccess.isStreamElement(fileName)) {
database.logger.log.deleteOldDataFiles();
fileAccess.removeElement(fileName);
if (fileAccess.isStreamElement(fileName)) {
String discardName = FileUtil.newDiscardFileName(fileName);
fileAccess.renameElement(fileName, discardName);
}
}
}
示例3: openFile
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* File is opened in append mode although in current usage the file
* never pre-exists
*/
protected void openFile() throws HsqlException {
try {
FileAccess fa = isDump ? FileUtil.getDefaultInstance()
: database.getFileAccess();
OutputStream fos = fa.openOutputStreamElement(outFile);
outDescriptor = fa.getFileSync(fos);
fileStreamOut = new BufferedOutputStream(fos, 2 << 12);
} catch (IOException e) {
throw Trace.error(Trace.FILE_IO_ERROR, Trace.Message_Pair,
new Object[] {
e.toString(), outFile
});
}
}
示例4: purge
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* Closes the source file and deletes it if it is not read-only.
*/
void purge() {
uncommittedCache.clear();
try {
if (cacheReadonly) {
close(false);
} else {
if (dataFile != null) {
dataFile.close();
dataFile = null;
}
FileUtil.getDefaultInstance().delete(fileName);
}
} catch (Exception e) {
throw Error.error(ErrorCode.FILE_IO_ERROR,
ErrorCode.M_TextCache_purging_file_error,
new Object[] {
fileName, e
});
}
}
示例5: openFile
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* File is opened in append mode although in current usage the file
* never pre-exists
*/
protected void openFile() {
try {
FileAccess fa = isDump ? FileUtil.getDefaultInstance()
: database.getFileAccess();
OutputStream fos = fa.openOutputStreamElement(outFile);
outDescriptor = fa.getFileSync(fos);
fileStreamOut = new BufferedOutputStream(fos, 2 << 12);
} catch (IOException e) {
throw Error.error(ErrorCode.FILE_IO_ERROR,
ErrorCode.M_Message_Pair, new Object[] {
e.toString(), outFile
});
}
}
示例6: deleteFile
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
static void deleteFile(Database database, String fileName) {
FileAccess fileAccess = database.logger.getFileAccess();
// first attemp to delete
fileAccess.removeElement(fileName);
if (database.logger.isStoredFileAccess()) {
return;
}
if (fileAccess.isStreamElement(fileName)) {
database.logger.log.deleteOldDataFiles();
fileAccess.removeElement(fileName);
if (fileAccess.isStreamElement(fileName)) {
String discardName = FileUtil.newDiscardFileName(fileName);
fileAccess.renameElement(fileName, discardName);
}
}
}
示例7: setFile
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* Initializes this object with the specified <code>File</code>
* object. <p>
*
* The file argument is a reference to this object's lock file. <p>
*
* This action has the effect of attempting to release any existing
* lock condition and reinitializing all lock-related member attributes
* @param file a reference to the file this object is to use as its
* lock file
*/
private void setFile(File file) throws Exception {
if (isLocked()) {
try {
tryRelease();
} catch (Exception e) {
trace(e);
}
}
f = FileUtil.canonicalFile(file);
cpath = f.getPath();
raf = null;
locked = false;
}
示例8: purge
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* Closes the source file and deletes it if it is not read-only.
*/
void purge() throws HsqlException {
if (dataFile == null) {
return;
}
try {
if (readOnly) {
close();
} else {
dataFile.close();
dataFile = null;
FileUtil.delete(sName);
}
} catch (Exception e) {
throw Trace.error(Trace.FILE_IO_ERROR,
Trace.TextCache_purging_file_error,
new Object[] {
sName, e
});
}
}
示例9: readScript
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
void readScript() throws HsqlException {
bRestoring = true;
try {
if (dDatabase.isFilesInJar() || FileUtil.exists(sFileScript)) {
ScriptReaderBase scr =
ScriptReaderBase.newScriptReader(dDatabase, sFileScript,
scriptFormat);
scr.readAll(dDatabase.sessionManager.getSysSession());
scr.close();
}
} catch (IOException e) {
throw Trace.error(Trace.FILE_IO_ERROR, e.getMessage());
}
if (!dDatabase.isFilesInJar() && FileUtil.exists(sFileLog)) {
ScriptRunner.runScript(dDatabase, sFileLog,
ScriptWriterBase.SCRIPT_TEXT_170);
}
bRestoring = false;
}
示例10: deleteFile
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
void deleteFile(boolean wasNio) {
// first attemp to delete
fa.removeElement(fileName);
// OOo related code
if (database.isStoredFileAccess()) {
return;
}
// OOo end
if (fa.isStreamElement(fileName)) {
if (wasNio) {
System.gc();
fa.removeElement(fileName);
}
if (fa.isStreamElement(fileName)) {
fa.renameElement(fileName, fileName + ".old");
File oldfile = new File(fileName + ".old");
FileUtil.getDefaultInstance().deleteOnExit(oldfile);
}
}
}
示例11: purge
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* Closes the source file and deletes it if it is not read-only.
*/
void purge() throws HsqlException {
uncommittedCache.clear();
try {
if (cacheReadonly) {
close(false);
} else {
if (dataFile != null) {
dataFile.close();
dataFile = null;
}
FileUtil.getDefaultInstance().delete(fileName);
}
} catch (Exception e) {
throw Trace.error(Trace.FILE_IO_ERROR,
Trace.TextCache_purging_file_error,
new Object[] {
fileName, e
});
}
}
示例12: putPropertiesFromFile
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* Attempts to put properties from the file
* with the specified path. The file
* extension '.properties' is implicit and should not
* be included in the path specification.
*
* @param path the path of the desired properties file, without the
* '.properties' file extension
* @throws RuntimeException if this server is running
* @return true if the indicated file was read sucessfully, else false
*
* @jmx.managed-operation
* impact="ACTION"
* description="Reads in properties"
*
* @jmx.managed-operation-parameter
* name="path"
* type="java.lang.String"
* position="0"
* description="(optional) returns false if path is empty"
*/
public boolean putPropertiesFromFile(String path) {
if (getState() != ServerConstants.SERVER_STATE_SHUTDOWN) {
throw new RuntimeException();
}
path = FileUtil.getDefaultInstance().canonicalOrAbsolutePath(path);
HsqlProperties p = ServerConfiguration.getPropertiesFromFile(path);
if (p == null || p.isEmpty()) {
return false;
}
printWithThread("putPropertiesFromFile(): [" + path + ".properties]");
try {
setProperties(p);
} catch (Exception e) {
throw new RuntimeException("Failed to set properties: " + e);
}
return true;
}
示例13: HsqlProperties
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
public HsqlProperties(String fileName, String fileExtension) {
stringProps = new Properties();
this.fileName = fileName;
this.fileExtension = fileExtension;
fa = FileUtil.getFileUtil();
}
示例14: initParams
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* Initial external parameters are set here. The size if fixed.
*/
protected void initParams(Database database, String baseFileName,
boolean defrag) {
this.dataFileName = baseFileName + ".data.tmp";
this.database = database;
fa = FileUtil.getFileUtil();
dataFileScale = 64;
cachedRowPadding = dataFileScale;
initialFreePos = dataFileScale;
maxCacheRows = 2048;
maxCacheBytes = maxCacheRows * 1024L;
maxDataFileSize = (long) Integer.MAX_VALUE * dataFileScale;
}
示例15: close
import org.hsqldb.lib.FileUtil; //导入依赖的package包/类
/**
* Writes newly created rows to disk. In the current implementation,
* such rows have already been saved, so this method just removes a
* source file that has no rows.
*/
public void close() {
if (dataFile == null) {
return;
}
writeLock.lock();
try {
cache.saveAll();
boolean empty = (dataFile.length()
<= textFileSettings.bytesForLineEnd.length);
dataFile.synch();
dataFile.close();
dataFile = null;
if (empty && !cacheReadonly) {
FileUtil.getFileUtil().delete(dataFileName);
}
uncommittedCache.clear();
} catch (Throwable t) {
throw Error.error(t, ErrorCode.FILE_IO_ERROR,
ErrorCode.M_TextCache_closing_file_error,
new Object[] {
t.toString(), dataFileName
});
} finally {
writeLock.unlock();
}
}