Reputation: 17753
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 inputStream. How to convert inputStream to FileInputStream? Or is there any other way, how to acces file from e.g. resources as a fileInputStream?
Thanks
Upvotes: 6
Views: 16609
Reputation: 30168
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.
Upvotes: 8
Reputation: 25761
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).
Upvotes: 4
Reputation: 25755
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?
Upvotes: 3