1 23 24 package com.sun.enterprise.util.shared; 25 26 import java.io.EOFException ; 27 import java.io.InputStream ; 28 import java.io.IOException ; 29 import java.io.OutputStream ; 30 31 37 public class ArchivistUtils { 38 39 43 public static void copy(InputStream is, OutputStream os) throws IOException { 44 copyWithoutClose(is, os); 45 is.close(); 46 os.close(); 47 } 48 49 53 public static void copyWithoutClose(InputStream is, OutputStream os) throws IOException { 54 byte[] buf = new byte[4096]; 55 int len = 0; 56 while (len != -1) { 57 try { 58 len = is.read(buf, 0, buf.length); 59 } catch (EOFException eof){ 60 break; 61 } 62 63 if(len != -1) { 64 os.write(buf, 0, len); 65 } 66 } 67 os.flush(); 68 } 69 } 70 | Popular Tags |