0. 缓存机制
- 缓存也可视为一种中间层,只是从缓存的角度,带来的不是底层细节的屏蔽,而是效率的提升;
1. 流式读取
比如网络 io(net io)
URL url = new URL("http://www.baidu.com"); InputStream inStream = url.openStream(); byte[] buffer = new byte[1024]; ByteArrayOutputStream outStream = new ByteArrayOutputStream(); int len = -1; while ((len = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, len); }