0
我想知道讀取存儲在Android SD卡上的大文件(50MB到100MB)花費多少時間的想法(大概)。我在Google Nexus One的Android 2.3.3上使用以下代碼。這會給我一個合理的估計嗎?是否有我應該使用的標準方法?另外,將使用本地代碼提高我的文件I/O性能?估算在Android上從SD卡讀取大文件的時間
謝謝。
public void readFileFromSDCard() throws IOException
{
long start = System.currentTimeMillis();
long size = 0;
File file = new File(OVERLAY_PATH_BASE + "base-ubuntu.vdi");
try {
InputStream in = new FileInputStream(file);
try {
byte[] tmp = new byte[4096];
int l;
while ((l = in.read(tmp)) != -1) {
size = size + 4096;
}
} finally {
in.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
long end = System.currentTimeMillis();
Log.e(LOG_TAG,
"Reading file " + file.getAbsolutePath() + " with " + size + "bytes took " + (end-start) + " ms.");
}