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