• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MoreFiles类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: readFromPath

import com.google.common.io.MoreFiles; //导入依赖的package包/类
/** Returns the application info read from either an app folder or ipa archive */
public static IosAppInfo readFromPath(Path ipaOrAppPath) throws IOException {
  NSObject plistDict;
  if (Files.isDirectory(ipaOrAppPath)) {
    plistDict = PlistParser.fromPath(ipaOrAppPath.resolve("Info.plist"));
  } else {
    try (FileSystem ipaFs = FileSystems.newFileSystem(ipaOrAppPath, null)) {
      Path appPath =
          MoreFiles.listFiles(ipaFs.getPath("Payload"))
              .stream()
              // Can't use Files.isDirectory, because no entry is a "directory" in a zip.
              .filter(e -> e.toString().endsWith(".app/"))
              .collect(MoreCollectors.onlyElement());
      plistDict = PlistParser.fromPath(appPath.resolve("Info.plist"));
    }
  }
  return readFromPlistDictionary((NSDictionary) plistDict);
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:19,代码来源:IosAppInfo.java


示例2: listSystemApps

import com.google.common.io.MoreFiles; //导入依赖的package包/类
static ImmutableSet<IosAppInfo> listSystemApps(String productVersion) throws IOException {
  try {
    return runtime2SystemApps.computeIfAbsent(
        productVersion,
        r ->
            tunnel(
                () -> {
                  Path appsDir = runtimeRootPath(productVersion).resolve("Applications");
                  return MoreFiles.listFiles(appsDir)
                      .stream()
                      .filter(p -> Files.exists(p.resolve("Info.plist")))
                      .map(a -> tunnel(() -> IosAppInfo.readFromPath(a)))
                      .collect(toImmutableSet());
                }));
  } catch (TunnelException e) {
    throw e.getCauseAs(IOException.class);
  }
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:19,代码来源:SimulatorDeviceHost.java


示例3: installApplication

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Override
public void installApplication(Path ipaOrAppPath) throws IosDeviceException {
  try {
    if (Files.isDirectory(ipaOrAppPath)) {
      await(simctl.install(ipaOrAppPath.toString()));
    } else {
      Path tmpDir = Files.createTempDirectory("app");
      try {
        unzipFile(ipaOrAppPath, tmpDir);
        Path appPath =
            tmpDir
                .resolve("Payload")
                .resolve(MoreFiles.getNameWithoutExtension(ipaOrAppPath) + ".app");
        await(simctl.install(appPath.toString()));
      } finally {
        MoreFiles.deleteRecursively(tmpDir, RecursiveDeleteOption.ALLOW_INSECURE);
      }
    }
  } catch (IOException e) {
    throw new IosDeviceException(this, e);
  }
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:23,代码来源:SimulatorDeviceImpl.java


示例4: writeFile

import com.google.common.io.MoreFiles; //导入依赖的package包/类
public static Single<WriteFileEvent> writeFile(final String content, final Path path, final boolean overwrite) {
    Preconditions.checkNotNull(content);
    Preconditions.checkNotNull(path);
    return Single.fromCallable(() -> {
        if (path.getParent() != null && !Files.exists(path.getParent())) {
            Files.createDirectories(path.getParent());
        }
        if (overwrite) {
            Files.deleteIfExists(path);
        } else if (Files.isDirectory(path)) {
            throw new IOException("There is already a directory at " + path);
        } else if (Files.exists(path)) {
            throw new IOException("There is already a file at " + path);
        }
        final ByteSink sink = MoreFiles.asByteSink(path);
        sink.write(content.getBytes());
        return WriteFileEvent.of(path);
    }).subscribeOn(Schedulers.io());
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:20,代码来源:CommonTasks.java


示例5: testCachingFile

import com.google.common.io.MoreFiles; //导入依赖的package包/类
public void testCachingFile() throws IOException {
  // Setup environment.
  String expectedContent = "// content content content";
  String newExpectedContent = "// new content new content new content";
  Path jsFile = Files.createTempFile("test", ".js");
  MoreFiles.asCharSink(jsFile, StandardCharsets.UTF_8).write(expectedContent);
  SourceFile sourceFile = SourceFile.fromFile(jsFile.toFile());

  // Verify initial state.
  assertEquals(expectedContent, sourceFile.getCode());

  // Perform a change.
  MoreFiles.asCharSink(jsFile, StandardCharsets.UTF_8).write(newExpectedContent);
  sourceFile.clearCachedSource();

  // Verify final state.
  assertEquals(newExpectedContent, sourceFile.getCode());
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:19,代码来源:SourceFileTest.java


示例6: createStatements

import com.google.common.io.MoreFiles; //导入依赖的package包/类
private List<StatementFileExporter> createStatements(LSql lSql, JavaExporter javaExporter, CliArgs cliArgs) {
    List<StatementFileExporter> list = newLinkedList();

    if (cliArgs.getSqlStatements() != null) {
        Path statementRootDir = new File(cliArgs.getSqlStatements()).toPath();
        Iterable<Path> children = MoreFiles.directoryTreeTraverser().preOrderTraversal(statementRootDir);
        for (Path child : children) {
            File file = child.toFile();
            if (file.isFile() && file.getName().endsWith(".sql")) {
                StatementFileExporter statementFileExporter =
                        new StatementFileExporter(lSql, javaExporter, file, cliArgs.getSqlStatements());

                list.add(statementFileExporter);
            }
        }
    }

    return list;
}
 
开发者ID:w11k,项目名称:lsql,代码行数:20,代码来源:Main.java


示例7: cleanUp

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@After
public void cleanUp() throws Exception {
    appContext.stopLogging();
    DataStore.closeConnection(dbconn);
    try {
        MoreFiles
            .deleteRecursively(Paths.get(DataStore.getDbDir(testDbName)), RecursiveDeleteOption.ALLOW_INSECURE);
    } catch (IOException e) {
        // DONT make test failure.
        System.err.println("test db clean-up failure, remove manually later :P");
        e.printStackTrace();
    }
}
 
开发者ID:SecureSkyTechnology,项目名称:burpextender-proxyhistory-webui,代码行数:14,代码来源:AppContextTest.java


示例8: close

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Override
public void close() {
    try {
        MoreFiles.deleteRecursively(fProjectPath);
    } catch (IOException e) {
    }
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:8,代码来源:StubProject.java


示例9: stopService

import com.google.common.io.MoreFiles; //导入依赖的package包/类
private void stopService() {
    try {
        brokerService.stop();
        MoreFiles.deleteRecursively(tempDir.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
        brokerService = null;
    } catch (Exception e) {
        throw new IllegalStateException("Could not stop broker", e);
    }
}
 
开发者ID:zapodot,项目名称:embedded-jms-junit,代码行数:10,代码来源:EmbeddedJmsRuleImpl.java


示例10: clearCrashLogs

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Override
public void clearCrashLogs() throws IosDeviceException {
  try {
    Path tempDir = Files.createTempDirectory("artifacts");
    try {
      idevice.crashreport(tempDir.toString());
    } finally {
      MoreFiles.deleteRecursively(tempDir, RecursiveDeleteOption.ALLOW_INSECURE);
    }
  } catch (IOException e) {
    throw new IosDeviceException(this, e);
  }
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:14,代码来源:RealDeviceImpl.java


示例11: toModel

import com.google.common.io.MoreFiles; //导入依赖的package包/类
private static IosModel toModel(String deviceType) throws IOException {
  checkArgument(deviceType.matches("[-\\w]*"));
  Path profileInfoBasePath =
      Paths.get(
          "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/"
              + "Developer/Library/CoreSimulator/Profiles/DeviceTypes");
  Path deviceTypePath =
      MoreFiles.listFiles(profileInfoBasePath)
          .stream()
          // The directory name that matches a given device type is the same as the name from the
          // device.plist file, with the hyphens replaced with spaces, hyphens, parentheses or
          // periods
          .filter(
              p -> MoreFiles.getNameWithoutExtension(p).replaceAll("\\W", "-").equals(deviceType))
          .collect(MoreCollectors.onlyElement());
  String rawProductName = MoreFiles.getNameWithoutExtension(deviceTypePath);
  String productName = GENERATION_PATTERN.matcher(rawProductName).replaceFirst("$1");

  Path profilePath = deviceTypePath.resolve("Contents/Resources/profile.plist");
  NSDictionary profileDict = (NSDictionary) PlistParser.fromPath(profilePath);
  String identifier = profileDict.get("modelIdentifier").toString();

  NSArray supportedArchs = (NSArray) profileDict.get("supportedArchs");
  // The supported architecture can either be just i386 or i386 and x86_64. The
  // actual architecture will be x86_64 if its supported, or i386 otherwise.
  Architecture architecture =
      supportedArchs.containsObject(Architecture.X86_64.toString())
          ? Architecture.X86_64
          : Architecture.I386;
  return IosModel.builder()
      .identifier(identifier)
      .productName(productName)
      .architecture(architecture)
      .build();
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:36,代码来源:SimulatorDeviceHost.java


示例12: userApps

import com.google.common.io.MoreFiles; //导入依赖的package包/类
private ImmutableSet<IosAppInfo> userApps() throws IOException {
  Path appPath =
      Paths.get(
          System.getProperty("user.home"),
          "Library/Developer/CoreSimulator/Devices",
          udid,
          "data/Containers/Bundle/Application");
  if (!Files.exists(appPath)) {
    return ImmutableSet.of();
  }
  try {
    return MoreFiles.listFiles(appPath)
        .stream()
        .map(
            p ->
                tunnel(
                    () ->
                        MoreFiles.listFiles(p)
                            .stream()
                            .filter(a -> MoreFiles.getFileExtension(a).equals("app"))
                            .collect(MoreCollectors.onlyElement())))
        .map(a -> tunnel(() -> IosAppInfo.readFromPath(a)))
        .collect(toImmutableSet());
  } catch (TunnelException e) {
    throw e.getCauseAs(IOException.class);
  }
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:28,代码来源:SimulatorDeviceImpl.java


示例13: emptyProject

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Test
public void emptyProject() throws Exception {

    final FileSystem fs = Jimfs.newFileSystem();

    // Workaround: JimFs does not implement .toFile;
    // We clone and fail buckaroo-recipes if it does not exist, so we create it.
    MoreFiles.createParentDirectories(fs.getPath(
        System.getProperty("user.home"),
        ".buckaroo",
        "buckaroo-recipes",
        ".git"));

    final Project project = Project.of();

    EvenMoreFiles.writeFile(
        fs.getPath("buckaroo.json"),
        Serializers.serialize(project));

    final Observable<Event> task = ResolveTasks.resolveDependenciesInWorkingDirectory(fs);

    task.toList().blockingGet();

    assertEquals(
        right(DependencyLocks.of()),
        Serializers.parseDependencyLocks(EvenMoreFiles.read(fs.getPath("buckaroo.lock.json"))));
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:28,代码来源:ResolveTasksTest.java


示例14: installDirectlyFromGitHub1

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Test
public void installDirectlyFromGitHub1() throws Exception {

    final FileSystem fs = Jimfs.newFileSystem();

    // Workaround: JimFs does not implement .toFile;
    // We clone and fail buckaroo-recipes if it does not exist, so we create it.
    MoreFiles.createParentDirectories(fs.getPath(
        System.getProperty("user.home"),
        ".buckaroo",
        "buckaroo-recipes",
        ".git"));

    final ImmutableList<PartialDependency> partialDependencies = ImmutableList.of(
        PartialDependency.of(
            Identifier.of("github"),
            Identifier.of("njlr"),
            Identifier.of("test-lib-a"),
            AnySemanticVersion.of()));

    InitTasks.initWorkingDirectory(fs).toList().blockingGet();

    final List<Event> events = InstallTasks.installDependencyInWorkingDirectory(fs, partialDependencies).toList().blockingGet();

    assertTrue(Files.exists(fs.getPath("BUCKAROO_DEPS")));

    final Path dependencyFolder = fs.getPath(
        "buckaroo", "github", "njlr", "test-lib-a");

    assertTrue(Files.exists(dependencyFolder.resolve("BUCK")));
    assertTrue(Files.exists(dependencyFolder.resolve("BUCKAROO_DEPS")));
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:33,代码来源:InstallTasksTest.java


示例15: installDirectlyFromGitHub2

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Test
public void installDirectlyFromGitHub2() throws Exception {

    final FileSystem fs = Jimfs.newFileSystem();

    // Workaround: JimFs does not implement .toFile;
    // We clone and fail buckaroo-recipes if it does not exist, so we create it.
    MoreFiles.createParentDirectories(fs.getPath(
        System.getProperty("user.home"),
        ".buckaroo",
        "buckaroo-recipes",
        ".git"));

    final ImmutableList<PartialDependency> partialDependencies = ImmutableList.of(
        PartialDependency.of(
            Identifier.of("github"),
            Identifier.of("njlr"),
            Identifier.of("test-lib-d"),
            AnySemanticVersion.of()));

    InitTasks.initWorkingDirectory(fs).toList().blockingGet();

    InstallTasks.installDependencyInWorkingDirectory(fs, partialDependencies).toList().blockingGet();

    assertTrue(Files.exists(fs.getPath("BUCKAROO_DEPS")));

    final Path dependencyFolder = fs.getPath(
        "buckaroo", "github", "njlr", "test-lib-d");

    assertTrue(Files.exists(dependencyFolder.resolve("BUCK")));
    assertTrue(Files.exists(dependencyFolder.resolve("BUCKAROO_DEPS")));
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:33,代码来源:InstallTasksTest.java


示例16: uninstallRemovesTheDependencyFromTheProjectFile

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Test
public void uninstallRemovesTheDependencyFromTheProjectFile() throws Exception {

    final FileSystem fs = Jimfs.newFileSystem();

    final Project project = Project.of(
        "My Project",
        DependencyGroup.of(ImmutableMap.of(
            RecipeIdentifier.of("org", "example"), AnySemanticVersion.of()
        )));

    Files.write(fs.getPath("buckaroo.json"), Serializers.serialize(project).getBytes(Charsets.UTF_8));

    // Workaround: JimFs does not implement .toFile;
    // We clone and fail buckaroo-recipes if it does not exist, so we create it.
    MoreFiles.createParentDirectories(fs.getPath(
        System.getProperty("user.home"),
        ".buckaroo",
        "buckaroo-recipes",
        ".git"));

    UninstallTasks.uninstallInWorkingDirectory(
        fs,
        ImmutableList.of(PartialRecipeIdentifier.of(Identifier.of("example")))).toList().blockingGet();

    final Project newProject = Serializers.parseProject(EvenMoreFiles.read(fs.getPath("buckaroo.json")))
        .right().get();

    assertTrue(!newProject.dependencies.requires(RecipeIdentifier.of("org", "example")));
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:31,代码来源:UninstallTasksTests.java


示例17: completeDependenciesFailsGracefully

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Test
public void completeDependenciesFailsGracefully() throws Exception {

    final FileSystem fs = Jimfs.newFileSystem();

    // Workaround: JimFs does not implement .toFile;
    // We clone and fail buckaroo-recipes if it does not exist, so we create it.
    MoreFiles.createParentDirectories(fs.getPath(
        System.getProperty("user.home"),
        ".buckaroo",
        "buckaroo-recipes",
        ".git"));

    final RecipeSource recipeSource = LazyCookbookRecipeSource.of(fs.getPath("nocookbookhere"));

    final ImmutableList<PartialDependency> partialDependencies = ImmutableList.of(
        PartialDependency.of(Identifier.of("org"), Identifier.of("example")));

    final CountDownLatch latch = new CountDownLatch(1);

    InstallTasks.completeDependencies(recipeSource, partialDependencies).result().subscribe(
        x -> {

        },
        error -> {
            latch.countDown();
        });

    latch.await(5000L, TimeUnit.MILLISECONDS);
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:31,代码来源:InstallTasksUnitTest.java


示例18: deleteRecursively

import com.google.common.io.MoreFiles; //导入依赖的package包/类
/**
 * Delete all the contents of a path recursively.
 *
 * <p>First we try to delete securely. In case the FileSystem doesn't support it,
 * delete it insecurely.
 */
public static void deleteRecursively(Path path) throws IOException {
  try {
    MoreFiles.deleteRecursively(path);
  } catch (InsecureRecursiveDeleteException ignore) {
    logger.warning(String.format("Secure delete not supported. Deleting '%s' insecurely.",
        path));
    MoreFiles.deleteRecursively(path, RecursiveDeleteOption.ALLOW_INSECURE);
  }
}
 
开发者ID:google,项目名称:copybara,代码行数:16,代码来源:FileUtil.java


示例19: createEnvironment

import com.google.common.io.MoreFiles; //导入依赖的package包/类
long createEnvironment(long cfg) {
  if (USE_GHOST_FILTER) {
    msat_set_option_checked(cfg, "dpll.ghost_filtering", "true");
  }

  msat_set_option_checked(cfg, "theory.la.split_rat_eq", "false");
  msat_set_option_checked(cfg, "random_seed", Long.toString(randomSeed));

  for (Entry<String, String> option : settings.furtherOptionsMap.entrySet()) {
    msat_set_option_checked(cfg, option.getKey(), option.getValue());
  }

  if (settings.logfile != null) {
    Path filename = settings.logfile.getFreshPath();
    try {
      MoreFiles.createParentDirectories(filename);
    } catch (IOException e) {
      logger.logUserException(Level.WARNING, e, "Cannot create directory for MathSAT logfile");
    }

    msat_set_option_checked(cfg, "debug.api_call_trace", "1");
    msat_set_option_checked(
        cfg, "debug.api_call_trace_filename", filename.toAbsolutePath().toString());
  }

  final long env;
  if (USE_SHARED_ENV) {
    env = msat_create_shared_env(cfg, creator.getEnv());
  } else {
    env = msat_create_env(cfg);
  }

  return env;
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:35,代码来源:Mathsat5SolverContext.java


示例20: reindexFromScratch

import com.google.common.io.MoreFiles; //导入依赖的package包/类
@Test
public void reindexFromScratch() throws Exception {
  setUpChange();

  MoreFiles.deleteRecursively(sitePaths.index_dir, RecursiveDeleteOption.ALLOW_INSECURE);
  Files.createDirectory(sitePaths.index_dir);
  assertServerStartupFails();

  runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
  assertReady(ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion());

  try (ServerContext ctx = startServer()) {
    GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
    // Query change index
    assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId))
        .containsExactly(changeId);
    // Query account index
    assertThat(gApi.accounts().query("admin").get().stream().map(a -> a._accountId))
        .containsExactly(adminId.get());
    // Query group index
    assertThat(
            gApi.groups()
                .query("Group")
                .withOption(MEMBERS)
                .get()
                .stream()
                .flatMap(g -> g.members.stream())
                .map(a -> a._accountId))
        .containsExactly(adminId.get());
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:ReindexIT.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DNSIncoming类代码示例发布时间:2022-05-22
下一篇:
Java Roles类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap