将InputStream写入本地文件
http://blog.csdn.net/hgg923/article/details/50698858
?
/**
?? ? * 將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();
?? ?}
---------------------?
作者:多來哈米?
來源:CSDN?
原文:https://blog.csdn.net/hgg923/article/details/50698858?
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!
總結
以上是生活随笔為你收集整理的将InputStream写入本地文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JavaWeb学习总结(一)——Java
- 下一篇: JavaWeb学习总结(二)——Tomc