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 ps 실행 했던 프로세스 docker ps -a 설치된 이미지 목록 docker images 도커 이미지 관리 이미지 받아오기 docker pull image이름 이...
-
DP 알고리즘 다이나믹 프로그래밍으로 동적 계획법이라고 한다. 해결해야할 문제를 작은 문제로 나눈 다음 작은 문제의 답을 얻고 저장한다. 그리고 그 작은 문제의 답을 필요할때마다 사용한다. 피보나치 수열을 예를 들면 f[n]=f[n-1]...
-
인스턴스 생성까지 끝낸 후 putty 다운 puttygen 으로 pem 파일을 ppk로 변경 ubuntu@~~~ 로 접속 sudo apt-get update 최신 버전엔 nodejs 와 npm이 포함되어 있다. sudo apt-ge...