2010-11-01 76 views
1

虽然从文件中读取下资产/ SB /例子/ simple.html /这是给filenotfound 例外。资产文件夹android中的Filenotfound异常?

11-01 18:30:13.562: WARN/System.err(912): java.io.FileNotFoundException: file:///android_asset/sb/example/simple.html 

代码段是

try { 
    final AssetManager assetMgr = ctx.getResources().getAssets(); 
    is = assetMgr.open(path, AssetManager.ACCESS_STREAMING); 
    // is = getAssets().open(file.getAbsolutePath()); 
} catch (IOException e1) { 
    // TODO Auto-generated catch block 
    e1.printStackTrace(); 
} 

回答

3

在这里,我给了资产的文件夹的完整路径,但在资产需要相对路径。

try { 
    final AssetManager assetMgr = ctx.getResources().getAssets(); 
    is = assetMgr.open("sb/example/simple1.html"); 
} catch (IOException e1) { 
    // TODO Auto-generated catch block 
    e1.printStackTrace(); 
} 

据工作....

相关问题