Java Modern Batch를 만들려고합니다. 모든 것이 규칙적으로 작동합니다 : 작업은 "HttpURLConnection"호출 단계의 "Initialize"메서드에 삽입 할 때까지 작업을 시작하고 종료합니다. HTTP 호출을 사용하면 실행이 차단 된 채로 있으며 매번 서버를 다시 시작해야합니다.Java에서 HttpURLConnection을 사용하는 방법 현대 배치
String url = "http://mywebsite.com/api.xml";
URL obj = new URL(url);
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader in = new BufferedReader(isr);
String inputLine;
StringBuffer response = new StringBuffer();
try {
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
}
catch (Exception e) {
// TODO: handle exception
}
isr.close();
in.close();
connection.disconnect();
String xml = response.toString();
응답 코드가 성공하지 않으면 입력 내용을 읽지 마십시오. – EJP