https in java, android

Post

url = new URL("https://112.169.59.24:4443/mmpcs/ua/initSync.do");
//HttpURLConnection conn = (HttpURLConnection) url.openConnection();
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();

conn.setDoOutput(true);
conn.setRequestMethod("POST");
String msg = "This is message for post";

OutputStreamWriter wr = new OutputStreamWriter(conn
.getOutputStream());
// this is were we're adding post data to the request
wr.write(msg);
wr.flush();

String str;
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
while ((str = in.readLine()) != null) {
    Log.i("TestApp",str);
}

in.close();
wr.close();

 

 

Get

url = new URL("https://112.169.59.24:4443/mmpcs/ua/initSync.do");
//HttpURLConnection conn = (HttpURLConnection) url.openConnection();
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setDoOutput(true);

String str;
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
while ((str = in.readLine()) != null) {
    Log.i("TestApp",str);
}

in.close();  

'Computing' 카테고리의 다른 글

CentOS 5.5, mongoDB, node.js  (0) 2011.05.19
iphone opengl camera ar  (0) 2011.05.18
x.inf contains DirIDs, which are not supported  (0) 2010.06.10
ffmpeg build  (0) 2010.06.04
VP8 And FFmpeg  (0) 2010.06.03