examples/dataflow-streaming-benchmark/src/test/java/com/google/cloud/pso/pipeline/StreamingBenchmarkTest.java
/**
   * Helper to generate files for testing.
   *
   * @param filePath The path to the file to write.
   * @param lines The lines to write.
   * @return The file written.
   * @throws IOException If an error occurs while creating or writing the file.
   */
Helper to generate files for testing.
@param filePath The path to the file to write.
@param lines The lines to write.
@return The file written.
@throws IOException If an error occurs while creating or writing the file.
Helper to generate files for testing . @param filePath The path to the file to write . @param lines The lines to write . @return The file written . @throws IOException If an error occurs while creating or writing the file .
private static ResourceId writeToFile(String filePath, List<String> lines) throws IOException {
    String fileContents = String.join(System.lineSeparator(), lines);
    ResourceId resourceId = FileSystems.matchNewResource(filePath, false);
    try (ReadableByteChannel readChannel =
        Channels.newChannel(new ByteArrayInputStream(fileContents.getBytes()))) {
      try (WritableByteChannel writeChannel = FileSystems.create(resourceId, MimeTypes.TEXT)) {
        ByteStreams.copy(readChannel, writeChannel);
      }
    }
    return resourceId;
  }
private static ResourceId writeToFile ( String filePath , List < String > lines ) throws IOException { String fileContents = String . join ( System . lineSeparator ( ) , lines ) ; ResourceId resourceId = FileSystems . matchNewResource ( filePath , false ) ; try ( ReadableByteChannel readChannel = Channels . newChannel ( new ByteArrayInputStream ( fileContents . getBytes ( ) ) ) ) { try ( WritableByteChannel writeChannel = FileSystems . create ( resourceId , MimeTypes . TEXT ) ) { ByteStreams . copy ( readChannel , writeChannel ) ; } } return resourceId ; }
Helper to generate files for testing.
Helper to generate files for testing .
// Write the file contents to the channel and close.