APISonar


com.google.common.io.Files.readFirstLine

> com > google > common > io > Files > readFirstLine
com APIs google APIs common APIs io APIs Files APIs readFirstLine APIs

Example 1
private static String getActiveGoogleCloudConfig(File configDir) {
    String activeGoogleCloudConfig = null;
    try {
      activeGoogleCloudConfig =
          Files.readFirstLine(new File(configDir, "active_config"), Charset.defaultCharset());
    } catch (IOException ex) {
      // ignore
    }
    // if reading active_config failed or the file is empty we try default
    return firstNonNull(activeGoogleCloudConfig, "default");
  }
Example 2
private static String readVersion(Path ndkRoot) {
    try {
      return Files.readFirstLine(
          ndkRoot.resolve("RELEASE.TXT").toFile(),
          Charset.defaultCharset()).trim();
    } catch (IOException e) {
      throw new HumanReadableException(
          e,
          "could not extract version from NDK repository at %s: %s",
          ndkRoot,
          e.getMessage());
    }
  }
Example 3
private String getPid() {
    final File libDir = PACKAGE_JAR.getParentFile();
    final File installDir = libDir.getParentFile();
    final File pidFile = new File(installDir, this.pidFilename);
    try {
      return Files.readFirstLine(pidFile, StandardCharsets.UTF_8).trim();
    } catch (final IOException e) {
      log.error("Unable to obtain PID", e);
      return "unknown";
    }
  }
Example 4
private void verifyTargetFile(File targetFile) throws IOException {
    String line = Files.readFirstLine(targetFile, Charset.forName("UTF-8"));
    Assert.assertEquals(FileRefTestUtil.TEXT, line);
  }
Example 5
private static RoaringBitmap read(String classPathResource) {
    try {
      RoaringBitmapWriter<RoaringBitmap> writer = RoaringBitmapWriter.writer().constantMemory().get();
      Arrays.stream(Files.readFirstLine(new File(classPathResource), Charset.forName("UTF-8")).split(","))
              .mapToInt(Integer::parseInt)
              .forEach(writer::add);
      writer.flush();
      return writer.getUnderlying();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Example 6
private GenericContainer createFrontend(final Network network) {
    final String image;
    try {
      image = Files.readFirstLine(new File("target/docker/image-name"), Charsets.UTF_8);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    return new GenericContainer(image)
        .withExposedPorts(1338)
        .withCommand("http://backend:" + BACKEND_PORT)
        .withNetwork(network)
        .withNetworkAliases("frontend");
  }
Example 7
private String buildServerAndClasspath() {
    new Build().of("//java/server/src/org/openqa/grid/selenium:selenium")
        .of("//java/server/src/org/openqa/grid/selenium:selenium:classpath")
        .go();

    String classpathFile = InProject.locate(
        "build/java/server/src/org/openqa/grid/selenium/selenium.classpath").getAbsolutePath();
    try {
      return Files.readFirstLine(new File(classpathFile), Charset.defaultCharset());
    } catch (IOException e) {
      Throwables.propagate(e);
    }

    return "";
  }
Example 8
public void testEtcdServerStarted() throws Exception {
    final String filePath = "target/jetcd-launcher-maven-plugin/endpoint";
    String endpoint = Files.readFirstLine(new File(filePath), US_ASCII);
    try (Client client = Client.builder().endpoints(endpoint).build()) {
      assertThat(client.getKVClient().get(Constants.NULL_KEY).get(7, TimeUnit.SECONDS).getCount()).isEqualTo(0);
    }
  }
Example 9
public void setUp() throws Exception {
    File file = testFolder.newFile("file.txt");
    String text = "hello";
    Files.write(text.getBytes(Charset.forName("UTF-8")), file);
    Assert.assertEquals(text, Files.readFirstLine(file, Charset.forName("UTF-8")));

    path = testFolder.getRoot().getAbsolutePath();
    setupSSHD(path);
    SSHClient sshClient = createSSHClient();

    SFTPClient sftpClient = sshClient.newSFTPClient();
    remoteFile = sftpClient.open(file.getName(), EnumSet.of(OpenMode.READ));
    remoteFile = Mockito.spy(remoteFile);
  }