1 17 package javax.servlet; 18 19 import java.io.InputStream ; 20 import java.io.IOException ; 21 22 45 46 public abstract class ServletInputStream extends InputStream { 47 48 49 50 54 55 protected ServletInputStream() { } 56 57 58 59 60 86 87 public int readLine(byte[] b, int off, int len) throws IOException { 88 89 if (len <= 0) { 90 return 0; 91 } 92 int count = 0, c; 93 94 while ((c = read()) != -1) { 95 b[off++] = (byte)c; 96 count++; 97 if (c == '\n' || count == len) { 98 break; 99 } 100 } 101 return count > 0 ? count : -1; 102 } 103 } 104 105 106 107 | Popular Tags |