【发布时间】:2010-10-05 09:59:36
【问题描述】:
谁能知道如何使用 Streams 读取位于 sdcard 中的二进制文件,例如 Inputstream、CountingInputStream 或 SwappedDataInputStream?
我正在使用这三个流来读取当前位于 Resources folder 中的文件,但现在我想将该文件移动到 sdcard 但我无法更改这些流,因为我已经做了很多工作并且我无法回滚我的工作。
我正在这样做,但它给了我FileNotFoundException。我需要你的帮助。
AssetManager assetManager = getResources().getAssets();
final File folder = new File(Environment.getExternalStorageDirectory() + "/map");
boolean success = false;
if(!folder.exists()){
success = folder.mkdir();
} else {
Log.i("folder already exists", "folder already exists");
}
try {
iStream = assetManager.open(Environment.getExternalStorageDirectory().getAbsolutePath().concat("/map/map.amf"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cis = new CountingInputStream(iStream);
input = new SwappedDataInputStream(cis);
非常感谢您的任何建议。
【问题讨论】:
标签: java android file filestream