Get file name from FileOutputStream

后端 未结 5 1062
别那么骄傲
别那么骄傲 2020-11-29 09:52

Is there a way to get the file name from a FileOutputStream or from FileInputStream?

5条回答
  •  长情又很酷
    2020-11-29 10:39

    This feature is not provided by the out-of-the-box File-Input/Output-Stream, but nothing stops you from writing your own subclass that stores the File (or fileName) and provides a getter for it.

    I would suggest implementing some FileNameAware interface for this), as I/O Streams are usually referenced with the InputStream / OutputStream abstract classes to avoid coupling your application with specific implementations.

提交回复
热议问题