일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- lsusb
- utf-8
- SQL Injection
- synology
- disabled
- readonly
- 시놀로지
- jQuery
- Injection
- replace
- println
- form
- submit
- javascript
- ASP
- PHP GCM
- include
- 커널
- Getrows
- 크로스 컴파일
- 무선랜카드
- AC1300
- DS718+
- ajax
- euc-kr
- 따라다니는 배너
- FileSystemObject
- jquery 레이어
- RTL88x2BU
- XMLHTTP
- Today
- Total
아는 것이 좋은 것이다.
[Java Programing] 특정 URL로 Json 전송 본문
// 연결
URL url = new URL("값을 보낼 URL");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST"); // 보내는 타입
conn.setRequestProperty("Accept-Language", "ko-kr,ko;q=0.8,en-us;q=0.5,en;q=0.3");
// 데이터
String param = "{\"title\": \"asdasd\", \"body\" : \"ddddddddd\"}";
// 전송
OutputStreamWriter osw = new OutputStreamWriter(
conn.getOutputStream());
try {
osw.write(param);
osw.flush();
// 응답
BufferedReader br = null;
br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
// 닫기
osw.close();
br.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
'Java Programing' 카테고리의 다른 글
[Java/JSP] return 없이 웹페이지에 값 보내기 (0) | 2015.01.27 |
---|---|
[Java] 파일 업로드, 임시파일 생성 (0) | 2015.01.21 |
[Java Programing] 배열에 특정값 삭제하기 (2) | 2014.10.24 |
[Java] URL 이미지 다운로드 (0) | 2014.06.09 |
[Java] 자바 로그 저장 (0) | 2014.06.03 |