1 21 package org.jacorb.orb.http.httpserver; 22 23 import java.io.*; 24 25 public class ServeInputStream extends InputStream 26 { 27 28 private InputStream in; 29 30 public ServeInputStream( InputStream in ) 31 { 32 this.in = in; 33 } 34 35 public int readLine( byte[] b, int off, int len ) throws IOException 36 { 37 int off2 = off; 38 while ( off2 - off < len ) 39 { 40 int r = read(); 41 if ( r == -1 ) 42 { 43 if (off2 == off ) 44 return -1; 45 break; 46 } 47 if ( r == 13 ) 48 continue; 49 if ( r == 10 ) 50 break; 51 b[off2] = (byte) r; 52 ++off2; 53 } 54 return off2 - off; 55 } 56 57 public int read() throws IOException 58 { 59 int b=in.read(); 60 return b; 61 } 62 63 public int read( byte[] b, int off, int len ) throws IOException 64 { 65 return in.read( b, off, len ); 66 } 67 68 public int available() throws IOException 69 { 70 return in.available(); 71 } 72 73 public void close() throws IOException 74 { 75 in.close(); 76 } 77 78 } 79 80 81 82 83 84 85 86 87 | Popular Tags |