| 62 | } |
| 63 | |
| 64 | public String readLine() throws IOException { |
| 65 | StringBuffer buf=new StringBuffer(); |
| 66 | |
| 67 | boolean eol=false; |
| 68 | while (true) { |
| 69 | |
| 70 | while (is.available()==0) |
| 71 | try { Thread.sleep(100); } catch (Exception e) { } |
| 72 | |
| 73 | int c = is.read(); |
| 74 | if (c<0) { |
| 75 | eol=true; |
| 76 | if (buf.length()==0) return null; |
| 77 | break; |
| 78 | } |
| 79 | if (c==0x0d || c==0x0a) { |
| 80 | eol=true; |
| 81 | //inputstream.mark(2); |
| 82 | if (c==0x0a) break; |
| 83 | } |
| 84 | else { |
| 85 | if (eol) { |
| 86 | //afterEol=c; |
| 87 | //inputstream.reset(); |
| 88 | break; |
| 89 | } |
| 90 | buf.append((char) c); |
| 91 | } |
| 92 | } |
| 93 | return buf.toString(); |
| 94 | } |
| 95 | |
| 96 | |
| 97 | public InputStream openInputStream() throws IOException { return is; } |