1 19 20 package org.netbeans.modules.proxy; 21 22 import java.io.FilterInputStream ; 23 import java.io.InputStream ; 24 import java.io.IOException ; 25 import java.io.InterruptedIOException ; 26 27 32 public class InterruptibleInputStream extends FilterInputStream { 33 34 public InterruptibleInputStream(InputStream in) { 35 super(in); 36 } 37 38 public int read() throws IOException { 39 waitAvailable(); 40 return in.read(); 41 } 42 43 public int read(byte b[], int off, int len) throws IOException { 44 waitAvailable(); 45 return super.read(b, off, len); 46 } 47 48 private void waitAvailable() throws IOException { 49 while (in.available() == 0) { 50 try { 51 Thread.sleep(100); 52 } catch (InterruptedException e) { 53 throw new InterruptedIOException (); 54 } 55 } 56 } 57 } 58 | Popular Tags |