package com.httpserver.one;import java.io.IOException;import java.io.InputStream;/***@project:HttpServerDemo*@author wuhn*@version 1.0*@createTime:2017年10月18日 下午12:22:14*@description: 接收浏览器发送过来的 URL字符串*/public class Receive {InputStream in=null;public Receive(InputStream in) {super();this.in = in;}/*** 该方法作用是将URL请求的文件返回*/public String parse(){StringBuffer receiveStr =new StringBuffer(2048);int i;byte[] buffer =new byte[2048];try {i = in.read(buffer);} catch (IOException e) {e.printStackTrace();i=-1;}for (int j = 0; j < i; j++) {receiveStr.append((char)buffer[j]); //将取得的信息,存到 receiveStr变量中}return getUri(receiveStr.toString());}private String getUri(String receiveStr) {int index1 , index2;index1 =receiveStr.indexOf(' ');if(index1 != -1){index2 = receiveStr.indexOf(' ',index1+1);if(index2 > index1 ){return receiveStr.substring(index1+1, index2);}}return null;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。