Buffer

package url;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Test1 {
public static void main(String[] args) {
StringBuffer msg=new StringBuffer();
String result="";
BufferedReader in=null;
String url="http://www.mingyigroup.net/testtwo/inwxsendapp.php";
try{
URL realUrl=new URL(url);
//打开和URL之间的链接
URLConnection connection=realUrl.openConnection();
connection.connect();
in=new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line=in.readLine())!=null){
msg.append(line);
}
String realMsg=msg.toString();
String fannlyMsg=realMsg.substring(realMsg.indexOf("!")+1);
System.out.println(fannlyMsg);
}catch (Exception e){
e.printStackTrace();
}
}
}
posted @ 2018-01-22 18:46  张小铁  阅读(216)  评论(0编辑  收藏  举报