0

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

4

1 回答 1

9

无需将其“转换”为 a FileInputStream,只需获取对的引用InputStream并使用它(BufferedInputStream如果需要,将其包装在 a 中)。

像这样 :

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);
于 2013-09-02T08:59:06.787 回答