일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- nmtui
- 퇴근버스 슈퍼스타K 2016
- HttpURLConnection
- 사랑 그렇게 보내네 김영근
- 내 자신의 생각
- 질투
- i7-8700
- 가식의 껍데기
- 보고싶은 내맘
- 흐린날의 낮술
- COC
- 3rd party software
- 지리산 소울 김영근
- rsnapshot
- 퇴근버스 조민욱
- 적절한 타이밍
- 커피레이크
- account ban
- 김영근 올패스
- CentOS 6 설치 오류
- #만취
- 넬 희망고문
- 그게 무슨 의미가 있니
- 도전의 기회
- 영구정지
- 해맑게 웃는 너
- 슈퍼스타k 2016
- 흘러가는대로
- 짝사랑
- 센티멘탈
- Today
- Total
끄적거림들...
HttpURLConnection 예제 본문
HttpURLConnection 예제 (POST)
try{
URL url = new URL("http://httpurlconnection.example");
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setDefaultUseCaches(false);
http.setDoInput(true);
http.setDoOutput(true);
http.setRequestMethod("POST");
http.setRequestProperty("content-type", "application/x-www-form-urlencoded");
OutputStreamWriter outStream = new OutputStreamWriter(http.getOutputStream(), "EUC-KR");
PrintWriter writer = new PrintWriter(outStream);
writer.flush();
InputStreamReader tmp = new InputStreamReader(http.getInputStream(), "EUC-KR");
BufferedReader reader = new BufferedReader(tmp);
StringBuilder builder = new StringBuilder();
String strResult;
while ((strResult = reader.readLine()) != null) {
builder.append(strResult + "\n");
}
Log.d(TAG, "result : " + builder.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
'Androiddd' 카테고리의 다른 글
Android DB 사용하기 예제 (0) | 2016.09.05 |
---|---|
FTP 파일 업로드하기 (FTPClient) (0) | 2016.09.05 |
HttpClient vs HttpURLConnection (0) | 2016.09.05 |
Android Bluetooth GamePad 연결하기 (0) | 2014.08.14 |
This Android SDK requires ADT version 23.0.0 or above (0) | 2014.07.28 |