Converting inputStream to FileInputStream?

前端 未结 3 1920
清歌不尽
清歌不尽 2021-01-13 05:14

I am in a problem - i need to read SecretKey from Android APK (e.g. key.keystore), for my app it has to be read as a FileInputStream, but from assets I am getting only input

相关标签:
3条回答
  • 2021-01-13 05:35

    I don't think this is possible because a FileInputStream is simply a InputStream for Files. It does the job of getting an InputStream from the defined file for you, after that you're working with a normal InputStream.

    Android already did this Job for you. So why do you need a FileInputStream?

    0 讨论(0)
  • 2021-01-13 05:42

    I think you are referring to AssetManager.open() that returns an InputStream. There is no need to "convert" it to a FileInputStream, just get the reference to the InputStream and use it (wrap it in a BufferedInputStream if you want).

    0 讨论(0)
  • 2021-01-13 05:53

    Why do you need a FileInputStream specifically? In general, you don't have to care about the underlying implementation of the InputStream, you just read from it. Maybe your implementation should be InputStream agnostic.

    0 讨论(0)
提交回复
热议问题