You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by dk...@apache.org on 2020/05/21 15:27:42 UTC

[avro] 02/02: Improve comments

This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 8c15c1241fb52f3ce6eb480bbe16ff70d3bc426a
Author: zeshuai007 <51...@qq.com>
AuthorDate: Thu Mar 5 10:27:52 2020 +0800

    Improve comments
---
 .../java/org/apache/avro/file/DataFileReader.java  | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java
index dc4206c..3c343f2 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileReader.java
@@ -88,12 +88,36 @@ public class DataFileReader<D> extends DataFileStream<D> implements FileReader<D
     return dreader;
   }
 
-  /** Construct a reader for a file. Please close resource files yourself. */
+  /**
+   * Construct a reader for a file. For example,if you want to read a file
+   * record,you need to close the resource. You can use try-with-resource as
+   * follows:
+   * 
+   * <pre>
+   * try (FileReader<User> dataFileReader =
+   * DataFileReader.openReader(file,datumReader)) { //Consume the reader } catch
+   * (IOException e) { throw new RunTimeIOException(e,"Failed to read metadata for
+   * file: %s", file); }
+   * 
+   * <pre/>
+   */
   public DataFileReader(File file, DatumReader<D> reader) throws IOException {
     this(new SeekableFileInput(file), reader, true);
   }
 
-  /** Construct a reader for a file. Please close resource files yourself. */
+  /**
+   * Construct a reader for a file. For example,if you want to read a file
+   * record,you need to close the resource. You can use try-with-resource as
+   * follows:
+   * 
+   * <pre>
+   * try (FileReader<User> dataFileReader =
+   * DataFileReader.openReader(file,datumReader)) { //Consume the reader } catch
+   * (IOException e) { throw new RunTimeIOException(e,"Failed to read metadata for
+   * file: %s", file); }
+   * 
+   * <pre/>
+   */
   public DataFileReader(SeekableInput sin, DatumReader<D> reader) throws IOException {
     this(sin, reader, false);
   }