質問

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