/**
* 将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();
}
/**
* 将bytes写入本地文件
* @param destination
* @param bytes
* @throws IOException
*/
private static void writeToLocal(String destination, byte[] bytes) throws IOException {
FileOutputStream downloadFile = new FileOutputStream(destination);
downloadFile.write(bytes);
downloadFile.flush();
downloadFile.close();
}