01: package com.sun.portal.netlet.client.jnlp.connect;
02:
03: import java.io.*;
04: import com.sun.portal.log.common.PortalLogger;
05:
06: public class HTTPRequestStream extends PushbackInputStream {
07:
08: public HTTPRequestStream(InputStream in) {
09: super (in);
10: }
11:
12: public String readLine() throws IOException {
13: StringBuffer line = new StringBuffer();
14: for (int c = read(); c != -1; c = read()) {
15: if (c == 13) {
16: int d = read();
17: if (d != 10)
18: unread(d);
19: break;
20: }
21: if (c == 10)
22: break;
23: line.append((char) c);
24: }
25:
26: return line.toString();
27: }
28:
29: public static void main(String[] args) {
30: try {
31: File f = new File("c:\\temp\\http_get_header.txt");
32: InputStream in = new FileInputStream(f);
33: HTTPRequestStream httpReqStrm = new HTTPRequestStream(in);
34: String temp = httpReqStrm.readLine();
35: while (!temp.equals("")) {
36: //Log.message(temp);
37: temp = httpReqStrm.readLine();
38: }
39: in.close();
40: } catch (Exception e) {
41:
42: }
43:
44: }
45: }
|