Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8129370

Typo in "The try-with-resources Statement"

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • docs
    • None

      In http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html

      static String readFirstLineFromFileWithFinallyBlock(String path)
                                                           throws IOException {
          BufferedReader br = new BufferedReader(new FileReader(path));
          try {
              return br.readLine();
          } finally {
              if (br != null) br.close();
          }
      }

      Remove the null check; it's redundant (there is no possibility of entering try block with a non-null BufferedReader)

            bhoran Bernard Horan (Inactive)
            rgallard Raymond Gallardo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: