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


Java FileUtils.delete方法代码示例

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


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

示例1: compact

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
/**
 * Copy all live pages from the source store to the target store.
 *
 * @param sourceFileName the name of the source store
 * @param targetFileName the name of the target store
 * @param compress whether to compress the data
 */
public static void compact(String sourceFileName, String targetFileName, boolean compress) {
    MVStore source = new MVStore.Builder().
            fileName(sourceFileName).
            readOnly().
            open();
    FileUtils.delete(targetFileName);
    MVStore.Builder b = new MVStore.Builder().
            fileName(targetFileName);
    if (compress) {
        b.compress();
    }
    MVStore target = b.open();
    compact(source, target);
    target.close();
    source.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:24,代码来源:MVStoreTool.java

示例2: testSpaceSeparated

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testSpaceSeparated() throws SQLException {
    deleteDb("csv");
    File f = new File(getBaseDir() + "/testSpace.csv");
    FileUtils.delete(f.getAbsolutePath());

    Connection conn = getConnection("csv");
    Statement stat = conn.createStatement();
    stat.execute("create temporary table test (a int, b int, c int)");
    stat.execute("insert into test values(1,2,3)");
    stat.execute("insert into test values(4,null,5)");
    stat.execute("call csvwrite('" + getBaseDir() +
            "/test.tsv','select * from test',null,' ')");
    ResultSet rs1 = stat.executeQuery("select * from test");
    assertResultSetOrdered(rs1, new String[][] {
            new String[] { "1", "2", "3" }, new String[] { "4", null, "5" } });
    ResultSet rs2 = stat.executeQuery("select * from csvread('" +
            getBaseDir() + "/test.tsv',null,null,' ')");
    assertResultSetOrdered(rs2, new String[][] {
            new String[] { "1", "2", "3" }, new String[] { "4", null, "5" } });
    conn.close();
    FileUtils.delete(f.getAbsolutePath());
    FileUtils.delete(getBaseDir() + "/test.tsv");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:24,代码来源:TestCsv.java

示例3: testRemoveMap

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testRemoveMap() throws Exception {
    String fileName = getBaseDir() + "/testCloseMap.h3";
    FileUtils.delete(fileName);
    MVStore s = new MVStore.Builder().
        fileName(fileName).
        open();
    MVMap<Integer, Integer> map;

    map = s.openMap("data");
    map.put(1, 1);
    assertEquals(1, map.get(1).intValue());
    s.commit();

    s.removeMap(map);
    s.commit();

    map = s.openMap("data");
    assertTrue(map.isEmpty());
    map.put(2, 2);

    s.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:TestMVStore.java

示例4: testPipe

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testPipe() throws SQLException {
    deleteDb("csv");
    Connection conn = getConnection("csv");
    Statement stat = conn.createStatement();
    stat.execute("call csvwrite('" + getBaseDir() +
            "/test.csv', 'select 1 id, ''Hello'' name', 'utf-8', '|')");
    ResultSet rs = stat.executeQuery("select * from csvread('" +
            getBaseDir() + "/test.csv', null, 'utf-8', '|')");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));
    assertEquals("Hello", rs.getString(2));
    assertFalse(rs.next());
    new File(getBaseDir() + "/test.csv").delete();

    // PreparedStatement prep = conn.prepareStatement("select * from
    // csvread(?, null, ?, ?)");
    // prep.setString(1, BASE_DIR+"/test.csv");
    // prep.setString(2, "utf-8");
    // prep.setString(3, "|");
    // rs = prep.executeQuery();

    conn.close();
    FileUtils.delete(getBaseDir() + "/test.csv");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:TestCsv.java

示例5: testReuseSpace

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testReuseSpace() {
    String fileName = getBaseDir() + "/testReuseSpace.h3";
    FileUtils.delete(fileName);
    long initialLength = 0;
    for (int j = 0; j < 20; j++) {
        MVStore s = openStore(fileName);
        s.setRetentionTime(0);
        MVMap<Integer, String> m = s.openMap("data");
        for (int i = 0; i < 10; i++) {
            m.put(i, "Hello");
        }
        s.commit();
        for (int i = 0; i < 10; i++) {
            assertEquals("Hello", m.get(i));
            assertEquals("Hello", m.remove(i));
        }
        s.close();
        long len = FileUtils.size(fileName);
        if (initialLength == 0) {
            initialLength = len;
        } else {
            assertTrue("len: " + len + " initial: " + initialLength + " j: " + j,
                    len <= initialLength * 2);
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:27,代码来源:TestMVStore.java

示例6: testCustomMapType

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testCustomMapType() {
    String fileName = getBaseDir() + "/testMapType.h3";
    FileUtils.delete(fileName);
    MVStore s = openStore(fileName);
    SequenceMap seq = s.openMap("data", new SequenceMap.Builder());
    StringBuilder buff = new StringBuilder();
    for (long x : seq.keySet()) {
        buff.append(x).append(';');
    }
    assertEquals("1;2;3;4;5;6;7;8;9;10;", buff.toString());
    s.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:13,代码来源:TestMVStore.java

示例7: test

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
@Override
public void test() throws Exception {
    if (config.networked) {
        return;
    }
    DeleteDbFiles.execute(getBaseDir(), null, true);
    org.h2.Driver.load();
    testSimpleResultSet();
    testTcpServerWithoutPort();
    testConsole();
    testJdbcDriverUtils();
    testWrongServer();
    testDeleteFiles();
    testScriptRunscriptLob();
    testServerMain();
    testRemove();
    testConvertTraceFile();
    testManagementDb();
    testChangeFileEncryption(false);
    if (!config.splitFileSystem) {
        testChangeFileEncryption(true);
    }
    testChangeFileEncryptionWithWrongPassword();
    testServer();
    testScriptRunscript();
    testBackupRestore();
    testRecover();
    FileUtils.delete(getBaseDir() + "/b2.sql");
    FileUtils.delete(getBaseDir() + "/b2.sql.txt");
    FileUtils.delete(getBaseDir() + "/b2.zip");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:32,代码来源:TestTools.java

示例8: testLargerThan2G

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testLargerThan2G() {
    if (!config.big) {
        return;
    }
    String fileName = getBaseDir() + "/testLargerThan2G.h3";
    FileUtils.delete(fileName);
    MVStore store = new MVStore.Builder().cacheSize(16).
            fileName(fileName).open();
    MVMap<Integer, String> map = store.openMap("test");
    long last = System.currentTimeMillis();
    String data = new String(new char[2500]).replace((char) 0, 'x');
    for (int i = 0;; i++) {
        map.put(i, data);
        if (i % 10000 == 0) {
            store.commit();
            long time = System.currentTimeMillis();
            if (time - last > 2000) {
                long mb = store.getFileStore().size() / 1024 / 1024;
                trace(mb + "/4500");
                if (mb > 4500) {
                    break;
                }
                last = time;
            }
        }
    }
    store.commit();
    store.close();
    FileUtils.delete(fileName);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:TestMVStore.java

示例9: testFastDelete

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testFastDelete() {
    String fileName = getBaseDir() + "/testFastDelete.h3";
    FileUtils.delete(fileName);
    MVStore s;
    MVMap<Integer, String> m;
    s = openStore(fileName, 700);
    m = s.openMap("data");
    for (int i = 0; i < 1000; i++) {
        m.put(i, "Hello World");
        assertEquals(i + 1, m.size());
    }
    assertEquals(1000, m.size());
    assertEquals(131896, s.getUnsavedMemory());
    s.commit();
    assertEquals(2, s.getFileStore().getWriteCount());
    s.close();

    s = openStore(fileName);
    m = s.openMap("data");
    m.clear();
    assertEquals(0, m.size());
    s.commit();
    // ensure only nodes are read, but not leaves
    assertEquals(41, s.getFileStore().getReadCount());
    assertTrue(s.getFileStore().getWriteCount() < 5);
    s.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:TestMVStore.java

示例10: testWriteRead

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testWriteRead() throws SQLException {
    deleteDb("csv");
    Connection conn = getConnection("csv");
    Statement stat = conn.createStatement();
    stat.execute("CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)");
    // int len = 100000;
    int len = 100;
    for (int i = 0; i < len; i++) {
        stat.execute("INSERT INTO TEST(NAME) VALUES('Ruebezahl')");
    }
    long time;
    time = System.currentTimeMillis();
    new Csv().write(conn, getBaseDir() + "/testRW.csv",
            "SELECT X ID, 'Ruebezahl' NAME FROM SYSTEM_RANGE(1, " + len + ")", "UTF8");
    trace("write: " + (System.currentTimeMillis() - time));
    ResultSet rs;
    time = System.currentTimeMillis();
    for (int i = 0; i < 30; i++) {
        rs = new Csv().read(getBaseDir() + "/testRW.csv", null, "UTF8");
        while (rs.next()) {
            // ignore
        }
    }
    trace("read: " + (System.currentTimeMillis() - time));
    rs = new Csv().read(getBaseDir() + "/testRW.csv", null, "UTF8");
    // stat.execute("CREATE ALIAS CSVREAD FOR \"org.h2.tools.Csv.read\"");
    ResultSetMetaData meta = rs.getMetaData();
    assertEquals(2, meta.getColumnCount());
    for (int i = 0; i < len; i++) {
        rs.next();
        assertEquals("" + (i + 1), rs.getString("ID"));
        assertEquals("Ruebezahl", rs.getString("NAME"));
    }
    assertFalse(rs.next());
    rs.close();
    conn.close();
    FileUtils.delete(getBaseDir() + "/testRW.csv");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:39,代码来源:TestCsv.java

示例11: 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

示例12: testConvertTraceFile

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testConvertTraceFile() throws Exception {
    deleteDb("toolsConvertTraceFile");
    org.h2.Driver.load();
    String url = "jdbc:h2:" + getBaseDir() + "/toolsConvertTraceFile";
    url = getURL(url, true);
    Connection conn = getConnection(url + ";TRACE_LEVEL_FILE=3", "sa", "sa");
    Statement stat = conn.createStatement();
    stat.execute(
            "create table test(id int primary key, name varchar, amount decimal)");
    PreparedStatement prep = conn.prepareStatement(
            "insert into test values(?, ?, ?)");
    prep.setInt(1, 1);
    prep.setString(2, "Hello \\'Joe\n\\'");
    prep.setBigDecimal(3, new BigDecimal("10.20"));
    prep.executeUpdate();
    stat.execute("create table test2(id int primary key,\n" +
            "a real, b double, c bigint,\n" +
            "d smallint, e boolean, f binary, g date, h time, i timestamp)",
            Statement.NO_GENERATED_KEYS);
    prep = conn.prepareStatement(
            "insert into test2 values(1, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    prep.setFloat(1, Float.MIN_VALUE);
    prep.setDouble(2, Double.MIN_VALUE);
    prep.setLong(3, Long.MIN_VALUE);
    prep.setShort(4, Short.MIN_VALUE);
    prep.setBoolean(5, false);
    prep.setBytes(6, new byte[] { (byte) 10, (byte) 20 });
    prep.setDate(7, java.sql.Date.valueOf("2007-12-31"));
    prep.setTime(8, java.sql.Time.valueOf("23:59:59"));
    prep.setTimestamp(9, java.sql.Timestamp.valueOf("2007-12-31 23:59:59"));
    prep.executeUpdate();
    conn.close();

    ConvertTraceFile.main("-traceFile", getBaseDir() +
            "/toolsConvertTraceFile.trace.db", "-javaClass", getBaseDir() +
            "/Test", "-script", getBaseDir() + "/test.sql");
    FileUtils.delete(getBaseDir() + "/Test.java");

    String trace = getBaseDir() + "/toolsConvertTraceFile.trace.db";
    assertTrue(FileUtils.exists(trace));
    String newTrace = getBaseDir() + "/test.trace.db";
    FileUtils.delete(newTrace);
    assertFalse(FileUtils.exists(newTrace));
    FileUtils.move(trace, newTrace);
    deleteDb("toolsConvertTraceFile");
    Player.main(getBaseDir() + "/test.trace.db");
    testTraceFile(url);

    deleteDb("toolsConvertTraceFile");
    RunScript.main("-url", url, "-user", "sa", "-script", getBaseDir() +
            "/test.sql");
    testTraceFile(url);

    deleteDb("toolsConvertTraceFile");
    FileUtils.delete(getBaseDir() + "/toolsConvertTraceFile.h2.sql");
    FileUtils.delete(getBaseDir() + "/test.sql");
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:58,代码来源:TestTools.java

示例13: testRandom

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testRandom() {
    String fileName = getBaseDir() + "/testRandom.h3";
    FileUtils.delete(fileName);
    MVStore s = openStore(fileName);
    MVMap<Integer, Integer> m = s.openMap("data");
    TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
    Random r = new Random(1);
    int operationCount = 1000;
    int maxValue = 30;
    Integer expected, got;
    for (int i = 0; i < operationCount; i++) {
        int k = r.nextInt(maxValue);
        int v = r.nextInt();
        boolean compareAll;
        switch (r.nextInt(3)) {
        case 0:
            log(i + ": put " + k + " = " + v);
            expected = map.put(k, v);
            got = m.put(k, v);
            if (expected == null) {
                assertNull(got);
            } else {
                assertEquals(expected, got);
            }
            compareAll = true;
            break;
        case 1:
            log(i + ": remove " + k);
            expected = map.remove(k);
            got = m.remove(k);
            if (expected == null) {
                assertNull(got);
            } else {
                assertEquals(expected, got);
            }
            compareAll = true;
            break;
        default:
            Integer a = map.get(k);
            Integer b = m.get(k);
            if (a == null || b == null) {
                assertTrue(a == b);
            } else {
                assertEquals(a.intValue(), b.intValue());
            }
            compareAll = false;
            break;
        }
        if (compareAll) {
            Iterator<Integer> it = m.keyIterator(null);
            Iterator<Integer> itExpected = map.keySet().iterator();
            while (itExpected.hasNext()) {
                assertTrue(it.hasNext());
                expected = itExpected.next();
                got = it.next();
                assertEquals(expected, got);
            }
            assertFalse(it.hasNext());
        }
    }
    s.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:63,代码来源:TestMVStore.java

示例14: testTools

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testTools() throws Exception {
    if (config.memory || config.cipher != null) {
        return;
    }
    deleteDb("web");
    Connection conn = getConnection("web");
    conn.createStatement().execute(
            "create table test(id int) as select 1");
    conn.close();
    Server server = new Server();
    server.setOut(new PrintStream(new ByteArrayOutputStream()));
    server.runTool("-web", "-webPort", "8182",
            "-properties", "null", "-tcp", "-tcpPort", "9101");
    try {
        String url = "http://localhost:8182";
        WebClient client;
        String result;
        client = new WebClient();
        result = client.get(url);
        client.readSessionId(result);
        result = client.get(url, "tools.jsp");
        FileUtils.delete(getBaseDir() + "/backup.zip");
        result = client.get(url, "tools.do?tool=Backup&args=-dir," +
                getBaseDir() + ",-db,web,-file," +
                getBaseDir() + "/backup.zip");
        deleteDb("web");
        assertTrue(FileUtils.exists(getBaseDir() + "/backup.zip"));
        result = client.get(url,
                "tools.do?tool=DeleteDbFiles&args=-dir," +
                getBaseDir() + ",-db,web");
        String fn = getBaseDir() + "/web";
        if (config.mvStore) {
            fn += Constants.SUFFIX_MV_FILE;
        } else {
            fn += Constants.SUFFIX_PAGE_FILE;
        }
        assertFalse(FileUtils.exists(fn));
        result = client.get(url, "tools.do?tool=Restore&args=-dir," +
                getBaseDir() + ",-db,web,-file," + getBaseDir() +
                "/backup.zip");
        assertTrue(FileUtils.exists(fn));
        FileUtils.delete(getBaseDir() + "/web.h2.sql");
        FileUtils.delete(getBaseDir() + "/backup.zip");
        result = client.get(url, "tools.do?tool=Recover&args=-dir," +
                getBaseDir() + ",-db,web");
        assertTrue(FileUtils.exists(getBaseDir() + "/web.h2.sql"));
        FileUtils.delete(getBaseDir() + "/web.h2.sql");
        result = client.get(url, "tools.do?tool=RunScript&args=-script," +
                getBaseDir() + "/web.h2.sql,-url," + getURL("web", true) +
                ",-user," + getUser() + ",-password," + getPassword());
        FileUtils.delete(getBaseDir() + "/web.h2.sql");
        assertTrue(FileUtils.exists(fn));
        deleteDb("web");
    } finally {
        server.shutdown();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:58,代码来源:TestWeb.java

示例15: testWriteDelay

import org.h2.store.fs.FileUtils; //导入方法依赖的package包/类
private void testWriteDelay() throws InterruptedException {
    String fileName = getBaseDir() + "/testWriteDelay.h3";
    MVStore s;
    MVMap<Integer, String> m;

    FileUtils.delete(fileName);
    s = new MVStore.Builder().
            autoCommitDisabled().
            fileName(fileName).open();
    m = s.openMap("data");
    m.put(1, "1");
    s.commit();
    s.close();
    s = new MVStore.Builder().
            autoCommitDisabled().
            fileName(fileName).open();
    m = s.openMap("data");
    assertEquals(1, m.size());
    s.close();

    FileUtils.delete(fileName);
    s = new MVStore.Builder().
            fileName(fileName).
            open();
    s.setAutoCommitDelay(1);
    m = s.openMap("data");
    m.put(1, "Hello");
    s.commit();
    long v = s.getCurrentVersion();
    m.put(2, "World.");
    Thread.sleep(5);
    // must not store, as nothing has been committed yet
    s.closeImmediately();
    s = new MVStore.Builder().
            fileName(fileName).
            open();
    s.setAutoCommitDelay(1);
    m = s.openMap("data");
    assertEquals("World.", m.get(2));
    m.put(2, "World");
    s.commit();
    v = s.getCurrentVersion();
    m.put(3, "!");

    for (int i = 100; i > 0; i--) {
        if (s.getCurrentVersion() > v) {
            break;
        }
        if (i < 10) {
            fail();
        }
        Thread.sleep(1);
    }
    s.closeImmediately();

    s = new MVStore.Builder().
            fileName(fileName).
            open();
    m = s.openMap("data");
    assertEquals("Hello", m.get(1));
    assertEquals("World", m.get(2));
    assertEquals("!", m.get(3));
    s.close();

    FileUtils.delete(fileName);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:67,代码来源:TestMVStore.java


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