IT/java

NEW URL

역신 2018. 11. 16. 10:05
SMALL

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();

     }




LIST