package com.haha.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class HttpTest {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String data = URLEncoder.encode("key1", "UTF-8") + "="
+ URLEncoder.encode("value1", "UTF-8");
data += "&" + URLEncoder.encode("key2", "UTF-8") + "="
+ URLEncoder.encode("value2", "UTF-8"); // Send
// data
URL url = new URL("http://192.168.180.4/NewCS/queryfee/queryFeeIndex.action");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush(); // Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn
.getInputStream()));
String line;
while ((line = rd.readLine()) != null) { // Process line...
System.out.println(line);
}
wr.close();
rd.close();
}
}