AndroidVideoCache
AndroidVideoCache copied to clipboard
怎么做到提前缓存啊?
public static void preCache(Executor executor, final HttpProxyCacheServer proxy, final String originUrl){
executor.execute(new Runnable() {
@Override
public void run() {
try {
InputStream inputStream = null;
URL url = new URL(proxy.getProxyUrl(originUrl));
inputStream = url.openStream();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int length = 0;
while ((length = inputStream.read(buffer)) != -1) {
//Since we just need to kick start the prefetching, dont need to do anything here
// or we can use ByteArrayOutputStream to write down the data to disk
}
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
读完不关闭流么?