Skip to main content

I came across similar requirement iso I used core javaJava's Connection URL API, - connection url apiURLConnection. It was verymuch faster:

String  myString = null;
URLConnection urlConn = null;
try{
    URL url = new URL("enter url here");
    urlConn = url.openConnection();
    urlConn.setUseCaches(false);
    HttpURLConnection httpConn = (HttpURLConnection)urlConn;
    InputStream is=null;
    if (httpConn.getResponseCode() >= 400) {
        if(httpConn.getErrorStream()!=null){
            is = httpConn.getErrorStream();
        }else{System.out.println("no error");}
    } else {
        is = httpConn.getInputStream();
    }
    myString = IOUtils.toString(is, "UTF-8");
    System.out.println(myString);
}catch(Exception e){
    throw new RuntimeException("Exception while calling url:",e);
}

I came across similar requirement i used core java - connection url api. It was very faster

String  myString = null;
URLConnection urlConn = null;
try{
    URL url = new URL("enter url here");
    urlConn = url.openConnection();
    urlConn.setUseCaches(false);
    HttpURLConnection httpConn = (HttpURLConnection)urlConn;
    InputStream is=null;
    if (httpConn.getResponseCode() >= 400) {
        if(httpConn.getErrorStream()!=null){
            is = httpConn.getErrorStream();
        }else{System.out.println("no error");}
    } else {
        is = httpConn.getInputStream();
    }
    myString = IOUtils.toString(is, "UTF-8");
    System.out.println(myString);
}catch(Exception e){
    throw new RuntimeException("Exception while calling url:",e);
}

I came across similar requirement so I used core Java's Connection URL API, URLConnection. It was much faster:

String  myString = null;
URLConnection urlConn = null;
try{
    URL url = new URL("enter url here");
    urlConn = url.openConnection();
    urlConn.setUseCaches(false);
    HttpURLConnection httpConn = (HttpURLConnection)urlConn;
    InputStream is=null;
    if (httpConn.getResponseCode() >= 400) {
        if(httpConn.getErrorStream()!=null){
            is = httpConn.getErrorStream();
        }else{System.out.println("no error");}
    } else {
        is = httpConn.getInputStream();
    }
    myString = IOUtils.toString(is, "UTF-8");
    System.out.println(myString);
}catch(Exception e){
    throw new RuntimeException("Exception while calling url:",e);
}

I came across similar requirement i used core java - connection url api. It was very faster

String myString = null; URLConnection urlConn = null; try{ URL url = new URL("enter url here"); urlConn = url.openConnection(); urlConn.setUseCaches(false); HttpURLConnection httpConn = (HttpURLConnection)urlConn; InputStream is=null; if (httpConn.getResponseCode() >= 400) { if(httpConn.getErrorStream()!=null){ is = httpConn.getErrorStream(); }else{System.out.println("no error");} } else { is = httpConn.getInputStream(); } myString = IOUtils.toString(is, "UTF-8"); System.out.println(myString); }catch(Exception e){ throw new RuntimeException("Exception while calling url:",e); }

String  myString = null;
URLConnection urlConn = null;
try{
    URL url = new URL("enter url here");
    urlConn = url.openConnection();
    urlConn.setUseCaches(false);
    HttpURLConnection httpConn = (HttpURLConnection)urlConn;
    InputStream is=null;
    if (httpConn.getResponseCode() >= 400) {
        if(httpConn.getErrorStream()!=null){
            is = httpConn.getErrorStream();
        }else{System.out.println("no error");}
    } else {
        is = httpConn.getInputStream();
    }
    myString = IOUtils.toString(is, "UTF-8");
    System.out.println(myString);
}catch(Exception e){
    throw new RuntimeException("Exception while calling url:",e);
}

I came across similar requirement i used core java - connection url api. It was very faster

String myString = null; URLConnection urlConn = null; try{ URL url = new URL("enter url here"); urlConn = url.openConnection(); urlConn.setUseCaches(false); HttpURLConnection httpConn = (HttpURLConnection)urlConn; InputStream is=null; if (httpConn.getResponseCode() >= 400) { if(httpConn.getErrorStream()!=null){ is = httpConn.getErrorStream(); }else{System.out.println("no error");} } else { is = httpConn.getInputStream(); } myString = IOUtils.toString(is, "UTF-8"); System.out.println(myString); }catch(Exception e){ throw new RuntimeException("Exception while calling url:",e); }

I came across similar requirement i used core java - connection url api. It was very faster

String  myString = null;
URLConnection urlConn = null;
try{
    URL url = new URL("enter url here");
    urlConn = url.openConnection();
    urlConn.setUseCaches(false);
    HttpURLConnection httpConn = (HttpURLConnection)urlConn;
    InputStream is=null;
    if (httpConn.getResponseCode() >= 400) {
        if(httpConn.getErrorStream()!=null){
            is = httpConn.getErrorStream();
        }else{System.out.println("no error");}
    } else {
        is = httpConn.getInputStream();
    }
    myString = IOUtils.toString(is, "UTF-8");
    System.out.println(myString);
}catch(Exception e){
    throw new RuntimeException("Exception while calling url:",e);
}
Added sample code, please check if it helps
Source Link

I came across similar requirement i used core java - connection url api. It was very faster

String myString = null; URLConnection urlConn = null; try{ URL url = new URL("enter url here"); urlConn = url.openConnection(); urlConn.setUseCaches(false); HttpURLConnection httpConn = (HttpURLConnection)urlConn; InputStream is=null; if (httpConn.getResponseCode() >= 400) { if(httpConn.getErrorStream()!=null){ is = httpConn.getErrorStream(); }else{System.out.println("no error");} } else { is = httpConn.getInputStream(); } myString = IOUtils.toString(is, "UTF-8"); System.out.println(myString); }catch(Exception e){ throw new RuntimeException("Exception while calling url:",e); }

I came across similar requirement i used core java - connection url api. It was very faster

I came across similar requirement i used core java - connection url api. It was very faster

String myString = null; URLConnection urlConn = null; try{ URL url = new URL("enter url here"); urlConn = url.openConnection(); urlConn.setUseCaches(false); HttpURLConnection httpConn = (HttpURLConnection)urlConn; InputStream is=null; if (httpConn.getResponseCode() >= 400) { if(httpConn.getErrorStream()!=null){ is = httpConn.getErrorStream(); }else{System.out.println("no error");} } else { is = httpConn.getInputStream(); } myString = IOUtils.toString(is, "UTF-8"); System.out.println(myString); }catch(Exception e){ throw new RuntimeException("Exception while calling url:",e); }

Source Link
Loading