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


Java FileUtils.createDirectories方法代码示例

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


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

示例1: openWriter

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private boolean openWriter() {
    if (printWriter == null) {
        try {
            FileUtils.createDirectories(FileUtils.getParent(fileName));
            if (FileUtils.exists(fileName) && !FileUtils.canWrite(fileName)) {
                // read only database: don't log error if the trace file
                // can't be opened
                return false;
            }
            fileWriter = IOUtils.getBufferedWriter(
                    FileUtils.newOutputStream(fileName, true));
            printWriter = new PrintWriter(fileWriter, true);
        } catch (Exception e) {
            logWritingError(e);
            return false;
        }
    }
    return true;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:TraceSystem.java

示例2: FileStore

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
/**
 * Create a new file using the given settings.
 *
 * @param handler the callback object
 * @param name the file name
 * @param mode the access mode ("r", "rw", "rws", "rwd")
 */
protected FileStore(DataHandler handler, String name, String mode) {
    this.handler = handler;
    this.name = name;
    try {
        boolean exists = FileUtils.exists(name);
        if (exists && !FileUtils.canWrite(name)) {
            mode = "r";
        } else {
            FileUtils.createDirectories(FileUtils.getParent(name));
        }
        file = FileUtils.open(name, mode);
        if (exists) {
            fileLength = file.size();
        }
    } catch (IOException e) {
        throw DbException.convertIOException(
                e, "name: " + name + " mode: " + mode);
    }
    this.mode = mode;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:FileStore.java

示例3: lockSerialized

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void lockSerialized() {
    method = SERIALIZED;
    FileUtils.createDirectories(FileUtils.getParent(fileName));
    if (FileUtils.createFile(fileName)) {
        properties = new SortedProperties();
        properties.setProperty("method", String.valueOf(method));
        setUniqueId();
        save();
    } else {
        while (true) {
            try {
                properties = load();
            } catch (DbException e) {
                // ignore
            }
            return;
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:FileLock.java

示例4: processMakeDir

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void processMakeDir(String param) {
    String fileName = getFileName(param);
    boolean ok = false;
    if (!readonly) {
        try {
            FileUtils.createDirectories(fileName);
            reply(257, StringUtils.quoteIdentifier(param) + " directory");
            ok = true;
        } catch (Exception e) {
            server.traceError(e);
        }
    }
    if (!ok) {
        reply(500, "Failed");
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:FtpControl.java

示例5: testDirectories

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private static void testDirectories(String fsBase) {
    final String fileName = fsBase + "/testFile";
    if (FileUtils.exists(fileName)) {
        FileUtils.delete(fileName);
    }
    if (FileUtils.createFile(fileName)) {
        new AssertThrows(DbException.class) {
            @Override
            public void test() {
                FileUtils.createDirectory(fileName);
        }};
        new AssertThrows(DbException.class) {
            @Override
            public void test() {
                FileUtils.createDirectories(fileName + "/test");
        }};
        FileUtils.delete(fileName);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:TestFileSystem.java

示例6: test

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
@Override
public void test() throws IOException {
    FileUtils.deleteRecursive(getBaseDir(), true);
    FileUtils.createDirectories(getBaseDir());
    testIOException();
    testSaveCount();
    testExceptionDuringStore();
    testReadCount();
    testLarge();
    testDetectIllegalId();
    testTreeStructure();
    testFormat();
    testWithExistingData();
    testWithFullMap();
    testLoop();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:TestStreamStore.java

示例7: test

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
@Override
public void test() throws Exception {
    FileUtils.deleteRecursive(getBaseDir(), true);
    FileUtils.createDirectories(getBaseDir());
    FileUtils.deleteRecursive("memFS:", false);

    testInterruptReopen();
    testConcurrentSaveCompact();
    testConcurrentDataType();
    testConcurrentAutoCommitAndChange();
    testConcurrentReplaceAndRead();
    testConcurrentChangeAndCompact();
    testConcurrentChangeAndGetVersion();
    testConcurrentFree();
    testConcurrentStoreAndRemoveMap();
    testConcurrentStoreAndClose();
    testConcurrentOnlineBackup();
    testConcurrentMap();
    testConcurrentIterate();
    testConcurrentWrite();
    testConcurrentRead();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:TestConcurrent.java

示例8: test

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
@Override
public void test() throws Exception {
    FileUtils.createDirectories(getBaseDir());
    testConcurrentAddRemove();
    testConcurrentAdd();
    testCountWithOpenTransactions();
    testConcurrentUpdate();
    testRepeatedChange();
    testTransactionAge();
    testStopWhileCommitting();
    testGetModifiedMaps();
    testKeyIterator();
    testMultiStatement();
    testTwoPhaseCommit();
    testSavepoint();
    testConcurrentTransactionsReadCommitted();
    testSingleConnection();
    testCompareWithPostgreSQL();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:TestTransactionStore.java

示例9: javacCompile

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
/**
 * Compile the given class. This method tries to use the class
 * "com.sun.tools.javac.Main" if available. If not, it tries to run "javac"
 * in a separate process.
 *
 * @param packageName the package name
 * @param className the class name
 * @param source the source code
 * @return the class file
 */
byte[] javacCompile(String packageName, String className, String source) {
    File dir = new File(COMPILE_DIR);
    if (packageName != null) {
        dir = new File(dir, packageName.replace('.', '/'));
        FileUtils.createDirectories(dir.getAbsolutePath());
    }
    File javaFile = new File(dir, className + ".java");
    File classFile = new File(dir, className + ".class");
    try {
        OutputStream f = FileUtils.newOutputStream(javaFile.getAbsolutePath(), false);
        Writer out = IOUtils.getBufferedWriter(f);
        classFile.delete();
        out.write(source);
        out.close();
        if (JAVAC_SUN != null) {
            javacSun(javaFile);
        } else {
            javacProcess(javaFile);
        }
        byte[] data = new byte[(int) classFile.length()];
        DataInputStream in = new DataInputStream(new FileInputStream(classFile));
        in.readFully(data);
        in.close();
        return data;
    } catch (Exception e) {
        throw DbException.convert(e);
    } finally {
        javaFile.delete();
        classFile.delete();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:42,代码来源:SourceCompiler.java

示例10: lockFile

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void lockFile() {
    method = FILE;
    properties = new SortedProperties();
    properties.setProperty("method", String.valueOf(method));
    setUniqueId();
    FileUtils.createDirectories(FileUtils.getParent(fileName));
    if (!FileUtils.createFile(fileName)) {
        waitUntilOld();
        String m2 = load().getProperty("method", FILE);
        if (!m2.equals(FILE)) {
            throw getExceptionFatal("Unsupported lock method " + m2, null);
        }
        save();
        sleep(2 * sleep);
        if (!load().equals(properties)) {
            throw getExceptionAlreadyInUse("Locked by another process");
        }
        FileUtils.delete(fileName);
        if (!FileUtils.createFile(fileName)) {
            throw getExceptionFatal("Another process was faster", null);
        }
    }
    save();
    sleep(SLEEP_GAP);
    if (!load().equals(properties)) {
        fileName = null;
        throw getExceptionFatal("Concurrent update", null);
    }
    watchdog = new Thread(this, "H2 File Lock Watchdog " + fileName);
    Driver.setThreadContextClassLoader(watchdog);
    watchdog.setDaemon(true);
    watchdog.setPriority(Thread.MAX_PRIORITY - 1);
    watchdog.start();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:35,代码来源:FileLock.java

示例11: start

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
@Override
public void start() {
    root = FileUtils.toRealPath(root);
    FileUtils.createDirectories(root);
    serverSocket = NetUtils.createServerSocket(port, false);
    port = serverSocket.getLocalPort();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:8,代码来源:FtpServer.java

示例12: testLZFStreamClose

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testLZFStreamClose() throws IOException {
    String fileName = getBaseDir() + "/temp";
    FileUtils.createDirectories(FileUtils.getParent(fileName));
    OutputStream fo = FileUtils.newOutputStream(fileName, false);
    LZFOutputStream out = new LZFOutputStream(fo);
    out.write("Hello".getBytes());
    out.close();
    InputStream fi = FileUtils.newInputStream(fileName);
    LZFInputStream in = new LZFInputStream(fi);
    byte[] buff = new byte[100];
    assertEquals(5, in.read(buff));
    in.read();
    in.close();
    FileUtils.delete(getBaseDir() + "/temp");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:16,代码来源:TestStreams.java

示例13: testSimpleExpandTruncateSize

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testSimpleExpandTruncateSize() throws Exception {
    String f = "memFS:" + getBaseDir() + "/fs/test.data";
    FileUtils.createDirectories("memFS:" + getBaseDir() + "/fs");
    FileChannel c = FileUtils.open(f, "rw");
    c.position(4000);
    c.write(ByteBuffer.wrap(new byte[1]));
    FileLock lock = c.tryLock();
    c.truncate(0);
    if (lock != null) {
        lock.release();
    }
    c.close();
    FileUtils.deleteRecursive("memFS:", false);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:15,代码来源:TestFileSystem.java

示例14: testPositionedReadWrite

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testPositionedReadWrite(String fsBase) throws IOException {
    FileUtils.deleteRecursive(fsBase + "/testFile", false);
    FileUtils.delete(fsBase + "/testFile");
    FileUtils.createDirectories(fsBase);
    assertTrue(FileUtils.createFile(fsBase + "/testFile"));
    FileChannel fc = FilePath.get(fsBase + "/testFile").open("rw");
    ByteBuffer buff = ByteBuffer.allocate(4000);
    for (int i = 0; i < 4000; i++) {
        buff.put((byte) i);
    }
    buff.flip();
    fc.write(buff, 96);
    assertEquals(0, fc.position());
    assertEquals(4096, fc.size());
    buff = ByteBuffer.allocate(4000);
    assertEquals(4000, fc.read(buff, 96));
    assertEquals(0, fc.position());
    buff.flip();
    for (int i = 0; i < 4000; i++) {
        assertEquals((byte) i, buff.get());
    }
    buff = ByteBuffer.allocate(0);
    assertTrue(fc.read(buff, 8000) <= 0);
    assertEquals(0, fc.position());
    assertTrue(fc.read(buff, 4000) <= 0);
    assertEquals(0, fc.position());
    assertTrue(fc.read(buff, 2000) <= 0);
    assertEquals(0, fc.position());
    buff = ByteBuffer.allocate(1);
    assertEquals(-1, fc.read(buff, 8000));
    assertEquals(1, fc.read(buff, 4000));
    buff.flip();
    assertEquals(1, fc.read(buff, 2000));
    fc.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:36,代码来源:TestFileSystem.java

示例15: testTempFilesDeleted

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testTempFilesDeleted(boolean stream) throws Exception {
    FileUtils.deleteRecursive(TEMP_DIR, true);
    FileUtils.createDirectories(TEMP_DIR);
    List<String> list = FileUtils.newDirectoryStream(TEMP_DIR);
    assertEquals("Unexpected temp file: " + list, 0, list.size());
    deleteDb("lob");
    Connection conn = getConnection("lob");
    Statement stat;
    stat = conn.createStatement();
    stat.execute("create table test(id int primary key, name text)");
    PreparedStatement prep = conn.prepareStatement(
            "insert into test values(2, ?)");
    if (stream) {
        String large = new String(new char[1024 * 1024 * 2]).replace((char) 0, 'x');
        prep.setCharacterStream(1, new StringReader(large), -1);
        large = null;
        prep.execute();
    } else {
        stat.execute("insert into test values(1, space(100000))");
    }
    /*
    list = FileUtils.newDirectoryStream(TEMP_DIR);
    assertEquals("Unexpected temp file: " + list, 0, list.size());
    */
    ResultSet rs;
    rs = stat.executeQuery("select * from test");
    while (rs.next()) {
        rs.getCharacterStream("name").close();
    }
    prep.close();
    conn.close();
    list = FileUtils.newDirectoryStream(TEMP_DIR);
    assertEquals("Unexpected temp file: " + list, 0, list.size());
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:35,代码来源:TestLob.java


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