일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- V8 Engine
- 공인인증서 정보
- Android NDK시스템
- IOS10
- Android
- 인증서 정보 뽑아내기
- Objective C
- apache
- android log dump
- ios
- ios framework
- embedd
- Push
- Magnify Anim
- PageControl
- sha1 convert hashkey
- v8 engine xcode build
- apk 다운사이징
- IMAGE
- so file
- appbarlayout
- Status Bar
- Google V8 Engine
- 공인인증서 만료일
- 안드로이드
- FlexiblePageView
- java
- apns
- SO 파일
- JavaScript Engine
- Today
- Total
caTea 블로그
http 데이터 송수신 클라이언트단 본문
protected <T, V> T process(URL url, boolean keepAilve , RequestMethod method, V param, class<T> clazz) throws IOException {
InoutStream is = null;
OutputStram os = null;
ReadableByteChannel rbc = null;
try{
HttpURLConnection conn= (HttpURLConnection) url.openConnection;
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod(method.name());
if(keepAilve){
conn.setTequestProperty("Connection", "keep-alive");
} else {
conn.setTequestProperty("Connection", "close");
}
conn.setReadTimeout(30000);
swith(method){
case get:{
break;
}
case POST : {
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
break;
}
ObjectMapper om = new ObjectMapper();
os = conn.getOutputStram();
os.write(om.writeValueAsBytes(params));
is = conn.getInputStream();
rbc = Channels.newChannel(is);
int size = is.available();
ByteBuffer buffer = ByteBuffer.allocate(size);
rbc.read(buffer);
buffer.filp();
rbc.close();
is.close();
os.close();
if(conn != null){
conn.disconnection();
}
ObjectReader or = om.reader(clazz);
return or.readValue(buffer.array());
} finally {
if (rbc != null){
try{rbc.close();}catch(Exception e){}
}
if (os != null){
try{os.close();}catch(Exception e){}
}
if (is != null){
try{is.close();}catch(Exception e){}
}
}
}
'spring(java)' 카테고리의 다른 글
바코드 생성 (0) | 2016.05.17 |
---|---|
html convert pdf (html문서를 pdf 파일로 변환) (0) | 2016.05.11 |
java mail sand example (0) | 2015.09.10 |
java excel paser example (0) | 2015.09.10 |
apache ftpclient example (0) | 2015.09.10 |