AndroidVideoCache icon indicating copy to clipboard operation
AndroidVideoCache copied to clipboard

怎么做到提前缓存啊?

Open fujiangren opened this issue 7 years ago • 2 comments

fujiangren avatar Oct 19 '18 23:10 fujiangren

  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();
                }
            }
        });
    }

dolwin avatar Oct 25 '18 02:10 dolwin

读完不关闭流么?

annybudong avatar Oct 29 '19 03:10 annybudong