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

有帮助吗?

解决方案

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);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top