0

.binファイルをandroidのアセットに入れました。読みたいです。私はこのルートを使用します:

fis = new FileInputStream("x:" + File.separator + "work"+File.separator+"game1"+File.separator+"File"+File.separator+"game1"+File.separator+"assets"+File.separator+"01.bin");

しかし、それは正しくありません。実行後、ファイルが見つからないことが表示されます。このファイルを取得する方法は?

4

2 に答える 2

1

これを試して..

AssetManager assetManager = getResources().getAssets();
InputStream input;
try
{
input = assetManager.open("01.bin");   
}
catch (IOException e)
{
e.printStackTrace();
}
于 2012-12-14T06:45:36.027 に答える
1

次のようなものを試してください:

AssetManager assetManager = getResources().getAssets();
InputStream inputStream = null;

    try {
        inputStream = assetManager.open("foo.txt");
            if ( inputStream != null)
                Log.d(TAG, "It worked!");
        } catch (IOException e) {
            e.printStackTrace();
        }

詳細な例については、このリンクを参照してください。

アセットからの Android 読み取りファイル

于 2012-12-14T06:37:12.777 に答える