본문 바로가기

IT/java

NEW URL

Java new URL


     URL serverobject = new URL(serverUrl);

     connection = (HttpURLConnection) serverobject.openConnection();

     connection.setConnectTimeout(1000);

     connection.setReadTimeout(3000);

     connection.setDoOutput(false);

     connection.setDoInput(true);

     connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

     connection.setRequestProperty("User-Agent", USER_AGENT);

     connection.setRequestProperty("Accept-Charset", "UTF-8");

     connection.setUseCaches(false);

     connection.setDefaultUseCaches(false);

     connection.connect();

     int serverResult = connection.getResponseCode();

     if(serverResult == HttpURLConnection.HTTP_OK){

             connection.disconnect();

     }




'IT > java' 카테고리의 다른 글

C#에서 JAVA 이미지 전송 및 Base64 디코더  (0) 2018.11.16
Java toByteArray  (0) 2018.11.16
java thread 모음  (0) 2018.05.02
JAVA에서 브라우저 URL 호출  (0) 2018.05.02
JAVA SERVER CLIENT EXE  (0) 2018.05.02