Question

I had used this code for opening a file

Context context = ...;
AssetManager assManager = context.getAssets();
InputStream is = assManager.open("test.crt");

But i want to use that file to write into file input stream

InputStream caInput = new BufferedInputStream(new FileInputStream("test.crt"));

Advance thanks for any help

Was it helpful?

Solution

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).

Like this :

AssetManager assManager = getApplicationContext().getAssets();
InputStream is = null;
try {
        is = assManager.open("test.crt");
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
InputStream caInput = new BufferedInputStream(is);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top