Should I close a StringReader?

前端 未结 5 601
小蘑菇
小蘑菇 2020-12-06 09:40

I use a StringReader to turn a string into something I can upload to an SFTP server (it takes a stream). Is there any point in closing that StringReader

5条回答
  •  旧时难觅i
    2020-12-06 10:20

    If you close the stream and release any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), or reset() invocations will throw an IOException. Closing a previously closed stream has no effect. Specified by: close in interface Closeable Specified by: close in class Reader

提交回复
热议问题