StringBuffer buffer =
new
StringBuffer();
try
{
URL url=
new
URL(address);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if
(connection !=
null
) {
connection.setDefaultUseCaches(
false
);
connection.setDoInput(
true
);
connection.setDoOutput(
true
);
connection.setRequestMethod(
"POST"
);
connection.setReadTimeout(
10000
);
connection.setConnectTimeout(
10000
);
connection.setRequestProperty(
"content-type"
,
"application/x-www-form-urlencoded"
);
String data = URLEncoder.encode(
"id"
,
"UTF-8"
) +
"="
+ URLEncoder.encode(
"gg"
,
"UTF-8"
);
data +=
"&"
+ URLEncoder.encode(
"pw"
,
"UTF-8"
) +
"="
+ URLEncoder.encode(
"zz"
,
"UTF-8"
);
OutputStreamWriter wr =
new
OutputStreamWriter(connection.getOutputStream());
wr.write(data);
wr.flush();
if
(connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
BufferedReader br =
new
BufferedReader(
new
InputStreamReader(connection.getInputStream(),
"euc-kr"
));
for
(;;) {
String line = br.readLine();
if
(line ==
null
)
break
;
buffer.append(line);
}
br.close();
}
connection.disconnect();
Message msg=mHandler.obtainMessage();
msg.what=
0
;
msg.arg1= Integer.parseInt(buffer.toString());
mHandler.sendMessage(msg);
}
}
catch
(MalformedURLException e) {
e.printStackTrace();
}
catch
(IOException e) {
e.printStackTrace();
}
}