7 Replies Latest reply: Sep 3, 2010 1:20 AM by EJP RSS

    Closing Reader without Closing InputStream

    843790
      Currently, I have a method :
      void method(InputStream stream) {
          // Create UTF-8 reader by wrapping up the stream.
      }
      The reason I do not want to have method to accept Reader is that, I want my own method to have own control to decide what type of encoding should be used.

      The problem is, whenever I close the Reader, InputStream will be closed as well. This is not my intention. As InputStream is "opened" by the caller. Hence, the closing operation on InputStream shall be done at caller side.

      Is there any way I can close the Reader in "method", without closing the InputStream passed by caller?

      Thanks.