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


Java Files类代码示例

本文整理汇总了Java中com.googlecode.totallylazy.Files的典型用法代码示例。如果您正苦于以下问题:Java Files类的具体用法?Java Files怎么用?Java Files使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: canZipAndUnzip

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
@Test
public void canZipAndUnzip() throws Exception {
    File playground = emptyVMDirectory("totallylazy");
    File a = file(playground, "a.txt");
    File b = file(playground, "folder/b.txt");
    File zipFile = temporaryFile();

    Zip.zip(playground, zipFile);

    Files.deleteFiles(playground);
    assertThat(a.exists(), is(false));
    assertThat(b.exists(), is(false));

    Zip.unzip(zipFile, playground);

    assertThat(a.exists(), is(true));
    assertThat(b.exists(), is(true));

    Files.deleteFiles(playground);
    zipFile.delete();
}
 
开发者ID:bodar,项目名称:totallylazy,代码行数:22,代码来源:ZipTest.java

示例2: preservesModifiedDate

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
@Test
public void preservesModifiedDate() throws Exception {
    File playground = emptyVMDirectory("totallylazy");
    File a = file(playground, "a.txt");
    Date date = date(2001, 1, 10);
    a.setLastModified(date.getTime());
    File zipFile = temporaryFile();

    Zip.zip(playground, zipFile);
    Files.deleteFiles(playground);
    Zip.unzip(zipFile, playground);

    assertThat(a.exists(), is(true));
    assertThat(new Date(a.lastModified()), is(date));

    Files.deleteFiles(playground);
    zipFile.delete();
}
 
开发者ID:bodar,项目名称:totallylazy,代码行数:19,代码来源:ZipTest.java

示例3: snap

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
@POST
@Hidden
@Path("snap")
@Produces(MediaType.APPLICATION_JSON)
public Response snap(@FormParam("id") String id) {
    Option<WebConsoleClientHandler> clientHandler = agent.client(id);

    if (!clientHandler.isEmpty()) {
        String snapId = UUID.randomUUID().toString();

        Files.write(clientHandler.get().history().toString("\n").getBytes(), snapFile(snapId));

        return ok()
                .entity(emptyMap(String.class, Object.class)
                        .insert("snap", snapId)
                        .insert("uri", snapUri(snapId).toString())
                );

    } else {
        return response(BAD_REQUEST);
    }
}
 
开发者ID:albertlatacz,项目名称:java-repl,代码行数:23,代码来源:WebConsoleResource.java

示例4: complete

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
@Override
public void complete(File yatspecOutputDir, Result result) throws Exception {
    final File output = outputFile(yatspecOutputDir, result);
    output.delete();
    output.getParentFile().mkdirs();
    String content = render(result);
    Files.write(content.getBytes("UTF-8"), output);
    System.out.println("Yatspec output:\n" + output);
}
 
开发者ID:bodar,项目名称:yatspec,代码行数:10,代码来源:FileRenderer.java

示例5: render

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
private void render(TreeMap<?, ?> map) {
    final File file = new File(Files.temporaryDirectory(), getClass().getSimpleName() + ".html");
    Files.write(bytes("<html><head><style>" +
            ".tree { border: 1px solid grey; padding: 0 1px; } " +
            ".key { text-align: center; } " +
            ".tree, .left, .right { display: table-cell; }" +
            "</style></head><body>" + new TreeMapRenderer().render(map) + "</body></html>"), file);
    System.out.println("tree = " + file);
}
 
开发者ID:bodar,项目名称:totallylazy,代码行数:10,代码来源:TreeVisualiser.java

示例6: save

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
public boolean save() {
    if (file.isEmpty())
        return false;

    try {
        Files.write(history.toString("\n").getBytes(), file.get());
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:albertlatacz,项目名称:java-repl,代码行数:12,代码来源:ConsoleHistory.java

示例7: savesAndLoadsMultilineHistory

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
@Test
public void savesAndLoadsMultilineHistory() {
    File historyFile = Files.temporaryFile();
    ConsoleHistory history = emptyHistory(never(), some(historyFile))
            .add("multiline\nexpression")
            .add("single line expression")
            .add("another\nmultiline\nexpression");

    history.save();

    assertThat(historyFromFile(never(), some(historyFile)).items(), is(history.items().map(replaceAll("\n", " "))));
}
 
开发者ID:albertlatacz,项目名称:java-repl,代码行数:13,代码来源:ConsoleHistoryTest.java

示例8: fileSource

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
public static FileSource fileSource(File folder) {
    return fileSource(folder, Files.recursiveFilesDirectoriesFirst(folder));
}
 
开发者ID:bodar,项目名称:totallylazy,代码行数:4,代码来源:FileSource.java

示例9: relativeTo

import com.googlecode.totallylazy.Files; //导入依赖的package包/类
public static Function1<File, Pair<String, File>> relativeTo(final File folder) {
    return file -> Pair.pair(Files.relativePath(folder, file), file);
}
 
开发者ID:bodar,项目名称:totallylazy,代码行数:4,代码来源:FileSource.java


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