URL url = new URL(FORM_URL);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
out.write("field=value&field=value&...");
out.flush();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
// do something
}
out.close();
in.close();
The only catch is to use URLEncoder.encode to translate keys and values to the x-form-url-encoded style.
No comments:
Post a Comment