求老师课件
老师能把课件传上来么,那是思维导图吧。。
老师能把课件传上来么,那是思维导图吧。。
2015-07-31
package com.example.http_02; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.nio.Buffer; import org.apache.http.HttpConnection; public class httpthred1 extends Thread { String url; String name; String age; public httpthred1(String url, String name, String age) { this.url = url; this.name = name; this.age = age; } private void doGet(){ url = url+"?name="+name+"&age="+age; try { URL httpurl = new URL(url); HttpURLConnection conn = (HttpURLConnection)httpurl.openConnection(); conn.setRequestMethod("GET"); conn.setReadTimeout(5000); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String str; StringBuffer sb = new StringBuffer(); while ((str=reader.readLine())!=null){sb.append(str);} System.out.println("result"+sb.toString()); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void doPost(){ try { URL httpurl = new URL(url); HttpURLConnection conn = (HttpURLConnection)httpurl.openConnection(); conn.setRequestMethod("POST"); conn.setReadTimeout(5000); OutputStream out = conn.getOutputStream(); String content="name="+name+"&age="+age; out.write(content.getBytes()); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); StringBuffer sb = new StringBuffer(); String str; while((str=reader.readLine())!=null){sb.append(str);} System.out.println("result"+sb.toString()); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void run() { doPost(); } }
举报