OK. If you want to simply read files from GCS, not as a PCollection but as regular files, and if you are having trouble with the GCS Java client libraries, you can also use the Apache Beam FileSystems API:
First, you need to make sure that you have a Maven dependency in your pom.xml
on beam-sdks-java-extensions-google-cloud-platform-core
which contains implementation of the gs://
filesystem:
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-extensions-google-cloud-platform-core</artifactId>
</dependency>
Then set up the FileSystems API (it is set up by default in all pipelines, but if you're using it outside a pipeline, you need to do it manually).
PipelineOptions options = PipelineOptionsFactory.create();
// ...Optionally fill in options such as GCP credentials...
// (see GcpOptions class)
FileSystems.setDefaultPipelineOptions(options);
Then you can use it:
ReadableByteChannel chan = FileSystems.open(FileSystems.matchNewResource(
"gs://path/to/your/file", false /* is_directory */));
try (InputStream stream = Channels.newInputStream(chan)) {
// Use regular Java utilities to work with the input stream.
}