1 4 package com.inversoft.savant; 5 6 7 import java.io.BufferedInputStream ; 8 import java.io.BufferedOutputStream ; 9 import java.io.File ; 10 import java.io.FileOutputStream ; 11 import java.io.IOException ; 12 import java.io.InputStream ; 13 14 15 23 public class FileTools { 24 25 34 public static void output(InputStream is, File output) 35 throws IOException { 36 BufferedInputStream bis = null; 37 BufferedOutputStream bos = null; 38 try { 39 bis = new BufferedInputStream (is); 40 bos = new BufferedOutputStream (new FileOutputStream (output)); 41 byte[] b = new byte[1024]; 42 int len; 43 while ((len = bis.read(b)) != -1) { 44 bos.write(b, 0, len); 45 } 46 } finally { 47 if (bis != null) { 48 bis.close(); 49 } 50 51 if (bos != null) { 52 bos.close(); 53 } 54 } 55 } 56 } 57 | Popular Tags |