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


Java FileUtils.isDirectory方法代码示例

本文整理汇总了Java中org.h2.store.fs.FileUtils.isDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.isDirectory方法的具体用法?Java FileUtils.isDirectory怎么用?Java FileUtils.isDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.store.fs.FileUtils的用法示例。


在下文中一共展示了FileUtils.isDirectory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printNoDatabaseFilesFound

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
/**
 * Print to the output stream that no database files have been found.
 *
 * @param dir the directory or null
 * @param db the database name or null
 */
protected void printNoDatabaseFilesFound(String dir, String db) {
    StringBuilder buff;
    dir = FileLister.getDir(dir);
    if (!FileUtils.isDirectory(dir)) {
        buff = new StringBuilder("Directory not found: ");
        buff.append(dir);
    } else {
        buff = new StringBuilder("No database files have been found");
        buff.append(" in directory ").append(dir);
        if (db != null) {
            buff.append(" for the database ").append(db);
        }
    }
    out.println(buff.toString());
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:Tool.java

示例2: processList

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void processList(String param, boolean directories) throws IOException {
    String directory = getFileName(param);
    if (!FileUtils.exists(directory)) {
        reply(450, "Directory does not exist");
        return;
    } else if (!FileUtils.isDirectory(directory)) {
        reply(450, "Not a directory");
        return;
    }
    String list = server.getDirectoryListing(directory, directories);
    reply(150, "Starting transfer");
    server.trace(list);
    // need to use the current locale (UTF-8 would be wrong for the Windows
    // Explorer)
    data.send(list.getBytes());
    reply(226, "Done");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:FtpControl.java

示例3: cat

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void cat(String fileName, long length) {
    if (!FileUtils.exists(fileName)) {
        print("No such file: " + fileName);
    }
    if (FileUtils.isDirectory(fileName)) {
        print("Is a directory: " + fileName);
    }
    InputStream inFile = null;
    try {
        inFile = FileUtils.newInputStream(fileName);
        IOUtils.copy(inFile, out, length);
    } catch (IOException e) {
        error(e);
    } finally {
        IOUtils.closeSilently(inFile);
    }
    println("");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:19,代码来源:FileShell.java

示例4: copy

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void copy(String fileName, FileStore in, byte[] key) {
    if (FileUtils.isDirectory(fileName)) {
        return;
    }
    String temp = directory + "/temp.db";
    FileUtils.delete(temp);
    FileStore fileOut;
    if (key == null) {
        fileOut = FileStore.open(null, temp, "rw");
    } else {
        fileOut = FileStore.open(null, temp, "rw", cipherType, key);
    }
    fileOut.init();
    byte[] buffer = new byte[4 * 1024];
    long remaining = in.length() - FileStore.HEADER_LENGTH;
    long total = remaining;
    in.seek(FileStore.HEADER_LENGTH);
    fileOut.seek(FileStore.HEADER_LENGTH);
    long time = System.currentTimeMillis();
    while (remaining > 0) {
        if (System.currentTimeMillis() - time > 1000) {
            out.println(fileName + ": " + (100 - 100 * remaining / total) + "%");
            time = System.currentTimeMillis();
        }
        int len = (int) Math.min(buffer.length, remaining);
        in.readFully(buffer, 0, len);
        fileOut.write(buffer, 0, len);
        remaining -= len;
    }
    in.close();
    fileOut.close();
    FileUtils.delete(fileName);
    FileUtils.move(temp, fileName);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:35,代码来源:ChangeFileEncryption.java

示例5: process

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private static void process(String fileName, boolean quiet) {
    if (FileUtils.isDirectory(fileName)) {
        // only delete empty directories
        FileUtils.tryDelete(fileName);
    } else if (quiet || fileName.endsWith(Constants.SUFFIX_TEMP_FILE) ||
            fileName.endsWith(Constants.SUFFIX_TRACE_FILE)) {
        FileUtils.tryDelete(fileName);
    } else {
        FileUtils.delete(fileName);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:12,代码来源:DeleteDbFiles.java

示例6: getDirectoryListing

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
/**
 * Get the directory listing for this directory.
 *
 * @param directory the directory to list
 * @param listDirectories if sub-directories should be listed
 * @return the list
 */
String getDirectoryListing(String directory, boolean listDirectories) {
    StringBuilder buff = new StringBuilder();
    for (String fileName : FileUtils.newDirectoryStream(directory)) {
        if (!FileUtils.isDirectory(fileName)
                || (FileUtils.isDirectory(fileName) && listDirectories)) {
            appendFile(buff, fileName);
        }
    }
    return buff.toString();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:FtpServer.java

示例7: processRemoveDir

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void processRemoveDir(String param) {
    String fileName = getFileName(param);
    if (!readonly && FileUtils.exists(fileName)
            && FileUtils.isDirectory(fileName)
            && FileUtils.tryDelete(fileName)) {
        reply(250, "Ok");
    } else {
        reply(500, "Failed");
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:11,代码来源:FtpControl.java

示例8: addFilesRecursive

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void addFilesRecursive(String f, ArrayList<String> target) {
    if (FileUtils.isDirectory(f)) {
        for (String c : FileUtils.newDirectoryStream(f)) {
            addFilesRecursive(c, target);
        }
    } else {
        target.add(getFile(f));
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:10,代码来源:FileShell.java

示例9: addFiles

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private static long addFiles(String dir, ArrayList<String> list) {
    long size = 0;
    for (String s : FileUtils.newDirectoryStream(dir)) {
        if (FileUtils.isDirectory(s)) {
            size += addFiles(s, list);
        } else {
            size += FileUtils.size(s);
        }
        list.add(s);
    }
    return size;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:13,代码来源:ArchiveToolStore.java

示例10: testRecover

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testRecover() throws SQLException {
    deleteDb("toolsRecover");
    org.h2.Driver.load();
    String url = getURL("toolsRecover", true);
    Connection conn = getConnection(url, "sa", "sa");
    Statement stat = conn.createStatement();
    stat.execute("create table test(id int primary key, " +
            "name varchar, b blob, c clob)");
    stat.execute("create table \"test 2\"(id int primary key, name varchar)");
    stat.execute("comment on table test is ';-)'");
    stat.execute("insert into test values" +
            "(1, 'Hello', SECURE_RAND(4100), '\u00e4' || space(4100))");
    ResultSet rs;
    rs = stat.executeQuery("select * from test");
    rs.next();
    byte[] b1 = rs.getBytes(3);
    String s1 = rs.getString(4);

    conn.close();
    Recover.main("-dir", getBaseDir(), "-db", "toolsRecover");

    // deleteDb would delete the .lob.db directory as well
    // deleteDb("toolsRecover");
    ArrayList<String> list = FileLister.getDatabaseFiles(getBaseDir(),
            "toolsRecover", true);
    for (String fileName : list) {
        if (!FileUtils.isDirectory(fileName)) {
            FileUtils.delete(fileName);
        }
    }

    conn = getConnection(url);
    stat = conn.createStatement();
    String suffix = ".h2.sql";
    stat.execute("runscript from '" + getBaseDir() + "/toolsRecover" +
            suffix + "'");
    rs = stat.executeQuery("select * from \"test 2\"");
    assertFalse(rs.next());
    rs = stat.executeQuery("select * from test");
    rs.next();
    assertEquals(1, rs.getInt(1));
    assertEquals("Hello", rs.getString(2));
    byte[] b2 = rs.getBytes(3);
    String s2 = rs.getString(4);
    assertEquals("\u00e4 ", s2.substring(0, 2));
    assertEquals(4100, b2.length);
    assertEquals(4101, s2.length());
    assertEquals(b1, b2);
    assertEquals(s1, s2);
    assertFalse(rs.next());
    conn.close();
    deleteDb("toolsRecover");
    FileUtils.delete(getBaseDir() + "/toolsRecover.h2.sql");
    String dir = getBaseDir() + "/toolsRecover.lobs.db";
    FileUtils.deleteRecursive(dir, false);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:57,代码来源:TestTools.java


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