将InputStream写入本地文件

来源:互联网 发布:桌面中考倒计时软件 编辑:程序博客网 时间:2024/04/27 20:10


/** * 将InputStream写入本地文件 * @param destination 写入本地目录 * @param input输入流 * @throws IOException */private static void writeToLocal(String destination, InputStream input)throws IOException {int index;byte[] bytes = new byte[1024];FileOutputStream downloadFile = new FileOutputStream(destination);while ((index = input.read(bytes)) != -1) {downloadFile.write(bytes, 0, index);downloadFile.flush();}downloadFile.close();input.close();}


1 0
原创粉丝点击