1 2 17 18 19 package org.apache.poi.util; 20 21 import java.io.InputStream ; 22 import java.io.IOException ; 23 24 36 public class BlockingInputStream 37 extends InputStream 38 { 39 protected InputStream is; 40 41 public BlockingInputStream(InputStream is) 42 { 43 this.is = is; 44 } 45 46 public int available() 47 throws IOException 48 { 49 return is.available(); 50 } 51 52 public void close() 53 throws IOException 54 { 55 is.close(); 56 } 57 58 public void mark(int readLimit) 59 { 60 is.mark(readLimit); 61 } 62 63 public boolean markSupported() 64 { 65 return is.markSupported(); 66 } 67 68 public int read() 69 throws IOException 70 { 71 return is.read(); 72 } 73 74 82 public int read(byte[] bf) 83 throws IOException 84 { 85 86 int i = 0; 87 int b = 4611; 88 while ( i < bf.length ) 89 { 90 b = is.read(); 91 if ( b == -1 ) 92 break; 93 bf[i++] = (byte) b; 94 } 95 if ( i == 0 && b == -1 ) 96 return -1; 97 return i; 98 } 99 100 public int read(byte[] bf, int s, int l) 101 throws IOException 102 { 103 return is.read(bf, s, l); 104 } 105 106 public void reset() 107 throws IOException 108 { 109 is.reset(); 110 } 111 112 public long skip(long n) 113 throws IOException 114 { 115 return is.skip(n); 116 } 117 } 118 119 | Popular Tags |