public String parse(InputStream in){
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String filename = null;
try {
String httpMessage = br.readLine();
String[] content = httpMessage.split("");
System.out.println("code: "+content[0]+",filename:"+content[1]+",version:"+content[2]);
in对象用来接受Socket.getInputStream(),就是浏览器传过来的信息;
比如我在流浪器中输入 http://localhost:8004/Test71501.html 最后的输出是什么呢?
在这里使用split("")来拆分对不对呢?
请教了;谢谢大家

解决方案 »

  1.   

    为什么我的输出是:code: ,filename:G,version:E  什么意思?怎么一点联系都没?
      

  2.   


    你还是先打印下httpMessage看是啥吧。
      

  3.   

    httpMessage 的内容是 GET Test71501.html Http/1.1 然后使用split(" ");来分割 
    我开始以为浏览器传过来的就是http://localhost:8004/Test71501.html 呢!