1 16 17 package org.apache.axis2.attachments; 18 import java.io.IOException ; 19 import java.io.InputStream ; 20 21 24 public class IOUtils 25 { 26 private IOUtils() { 27 } 28 29 36 public static int readFully(InputStream in, byte[] b) 37 throws IOException 38 { 39 return readFully(in, b, 0, b.length); 40 } 41 42 49 public static int readFully(InputStream in, byte[] b, int off, int len) 50 throws IOException 51 { 52 int total = 0; 53 for (;;) { 54 int got = in.read(b, off + total, len - total); 55 if (got < 0) { 56 return (total == 0) ? -1 : total; 57 } else { 58 total += got; 59 if (total == len) 60 return total; 61 } 62 } 63 } 64 } | Popular Tags |