HttpURLConnection con;
String url;
HttpReq() {
}
HttpReq(String url) throws IOException {
this.url = url;
URL myurl = new URL(url);
con = (HttpURLConnection) myurl.openConnection();
}
void closeServer() {
con.disconnect();
}
public StringBuilder get() throws IOException {
StringBuilder content;
con.setRequestMethod("GET");
try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
String line;
content = new StringBuilder();
while ((line = in.readLine()) != null) {
content.append(line);
content.append(System.lineSeparator());
}
}
System.out.println(content.toString());
return content;
}
public StringBuilder post() throws IOException {
String urlParameters = "name=Jack&occupation=programmer";
StringBuilder content;
byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);
con.setDoOutput(true);
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", "Java client");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
wr.write(postData);
}
try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
String line;
content = new StringBuilder();
while ((line = in.readLine()) != null) {
content.append(line);
content.append(System.lineSeparator());
}
}
System.out.println(content.toString());
return content;
}
2018년 10월 22일 월요일
flutter 기본 개념 1
Scaffold - 화면 뼈대 역할 - 기본적으로 AppBar body floatingActionButton 같은걸 배치해줌 return Scaffold ( appBar : AppBar ( title : const Text ...
-
도커(Docker)란? - OS가상화보다 가볍고 빠르다. - 하드웨어에서 독립적인 공간을 차지하고 (docker 이미지에서 서버 운영을 위한 프로그램과 라이브러리를 격리해서 설치) OS 자원(시스템 콜)은 호스트와 공유 - 독립적인 공간은 컨테...
-
nodejs 특징 비동기식 단일쓰레드 이벤트루프 작은 데이터가 많을때 좋음 단일쓰레드라 큰 함수를 다룰때 안좋음 npm이라는 가장큰 라이브러리를 보유 싱글 스레드 -> 콜스텍이 하나 web api...
-
DP 알고리즘 다이나믹 프로그래밍으로 동적 계획법이라고 한다. 해결해야할 문제를 작은 문제로 나눈 다음 작은 문제의 답을 얻고 저장한다. 그리고 그 작은 문제의 답을 필요할때마다 사용한다. 피보나치 수열을 예를 들면 f[n]=f[n-1]...