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

Typo in "The try-with-resources Statement"

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: docs
    • Labels:
      None

      Description

      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)

        Attachments

          Activity

            People

            Assignee:
            bhoran Bernard Horan
            Reporter:
            rgallard Raymond Gallardo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: