Java IO

byte[] buff = new byte[1024];
BufferedInputStream bis = null;
OutputStream os = null;
try {
os = res.getOutputStream();
bis = new BufferedInputStream(new FileInputStream(file));
int i = bis.read(buff);
while (i != -1) {
os.write(buff, 0, i);
os.flush();
i = bis.read(buff);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
posted @ 2017-10-26 15:21  涉谷猫猫  阅读(150)  评论(0编辑  收藏  举报