当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil类代码示例

本文整理汇总了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;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:22,代码来源:TextCache.java

示例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);
            }
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:23,代码来源:DataFileCache.java

示例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
        });
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:ScriptWriterBase.java

示例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
        });
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:28,代码来源:TextCache.java

示例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
        });
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:21,代码来源:ScriptWriterBase.java

示例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);
            }
        }
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:23,代码来源:DataFileCache.java

示例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;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:LockFile.java

示例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
        });
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:TextCache.java

示例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;
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:Log.java

示例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);
            }
        }
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:DataFileCache.java

示例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
        });
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:TextCache.java

示例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;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:Server.java

示例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();
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:8,代码来源:HsqlProperties.java

示例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;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:17,代码来源:DataFileCacheSession.java

示例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();
    }
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:40,代码来源:TextCache.java


注:本文中的org.hsqldb.lib.FileUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。