writeFileToTable in BigQuerySnippets.java needs to close channel #4918
Labels
api: bigquery
Issues related to the BigQuery API.
type: docs
Improvement to the documentation for an API.
File: google-cloud-java/google-cloud-examples/src/main/java/com/google/cloud/examples/bigquery/snippets/BigQuerySnippets.java
Issue: (at Line: 430)
In the example of writing a local file to a table (public long writeFileToTable(String datasetName, String tableName, Path csvPath, String location) throws IOException, InterruptedException, TimeoutException), TableDataWriteChannel needs to be closed.
Solution: replace line 428-430 with the following code snippet:
try (OutputStream stream = Channels.newOutputStream(writer)) { Files.copy(csvPath, stream); } finally { writer.close(); }
The text was updated successfully, but these errors were encountered: