我的Android應用程序從服務器下載一堆照片和視頻,我想緩存這些數據。我已經使用DiskLruCach庫緩存圖像,它工作正常,但現在我想緩存視頻也。DiskLruCache視頻
我已經試過這樣的事情,但它似乎沒有工作 - 我無法找到在緩存目錄中的視頻東西:
private boolean writeVideoToFile(String videoUri, DiskLruCache.Editor editor) throws IOException, FileNotFoundException {
OutputStream out = null;
FileOutputStream fos;
try {
out = new BufferedOutputStream(editor.newOutputStream(0), Utils.IO_BUFFER_SIZE);
File videoFile = Utils.createFile(Utils.TYPE_VIDEO_FILE);
fos = new FileOutputStream(videoFile);
fos.write(videoUri.getBytes());
fos.close();
return true;
} finally {
if (out != null) {
out.close();
}
}
}
誰能給我如何我的IDEEA可以做到這一點?
我已經放棄了這段代碼!現在我正在使用一個簡單的DiskLruCache實現。它適用於位圖,但我遇到了視頻部分的問題。請參閱此鏈接 - http://stackoverflow.com/questions/17382065/simplediskcache-inputstream-bad-number-format如果您有任何ideea,請分享!謝謝! – Alin