This code sample shows how to extract details from inspection findings that are
saved in Protobuf text format. Do this task if you [saved your inspection
findings to
Cloud Storage](https://docs.cloud.google.com/sensitive-data-protection/docs/concepts-actions#save-findings-cloud-storage).
This example converts the exported
[`SaveToGcsFindingsOutput`](https://docs.cloud.google.com/sensitive-data-protection/docs/reference/rest/v2/SaveToGcsFindingsOutput.md.txt) object
into a human-readable format. You can then use the output to analyze individual
inspection findings.

### Java


To learn how to install and use the client library for Sensitive Data Protection, see
[Sensitive Data Protection client libraries](https://docs.cloud.google.com/sensitive-data-protection/docs/libraries.md.txt).


To authenticate to Sensitive Data Protection, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```java

import com.google.privacy.dlp.v2.Finding;
import com.google.privacy.dlp.v2.SaveToGcsFindingsOutput;
import com.google.protobuf.ByteString;
import com.google.protobuf.TextFormat;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;

public class ProcessInspectFindingsSavedToGcs {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String inputPath = "src/test/resources/save_to_gcs_findings.txt";
    processFindingsGcsFile(inputPath);
  }

  // Processes a file containing findings from a DLP inspect job.
  public static void processFindingsGcsFile(String inputPath)
      throws IOException {
    SaveToGcsFindingsOutput.Builder builder = SaveToGcsFindingsOutput.newBuilder();
    try (Reader reader =
        new InputStreamReader(new FileInputStream(inputPath), StandardCharsets.UTF_8)) {
      TextFormat.merge(reader, builder);
    }
    SaveToGcsFindingsOutput output = builder.build();

    // Parse the converted proto and process results
    System.out.println("Findings: " + output.getFindingsCount());
    for (Finding f : output.getFindingsList()) {
      System.out.println("\tInfo type: " + f.getInfoType().getName());
      System.out.println("\tLikelihood: " + f.getLikelihood());
    }
  }
}
```