Package java.net

Examples of java.net.HttpURLConnection.disconnect()


    } catch (final Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    } finally {
      if (conn != null) {
        conn.disconnect();
      }
    }
  }

}
View Full Code Here


        HttpURLConnection httpConnection = (HttpURLConnection) connection;
        httpConnection.setConnectTimeout(timeout * 1000);
        httpConnection.setReadTimeout(timeout * 1000);
        httpConnection.connect();
        int response = httpConnection.getResponseCode();
        httpConnection.disconnect();
        return response == HttpURLConnection.HTTP_OK;
      }
    } catch (Exception e) {
      return false;
    }
View Full Code Here

        HttpURLConnection httpConnection = (HttpURLConnection) connection;
        httpConnection.setConnectTimeout(timeout * 1000);
        httpConnection.setReadTimeout(timeout * 1000);
        httpConnection.connect();
        int response = httpConnection.getResponseCode();
        httpConnection.disconnect();
        return response;
      }
    } catch (IOException e) {
      // pass
    }
View Full Code Here

            HttpURLConnection huc = (HttpURLConnection)uc;
            huc.setInstanceFollowRedirects(false);
            huc.connect();
            int responseCode = huc.getResponseCode();
            String location = huc.getHeaderField("location");
            huc.disconnect();
            if ((responseCode == HttpURLConnection.HTTP_MOVED_TEMP) && (redirectCount < 5)) {
                //System.out.println(responseCode);
                //System.out.println(location);
                try {
                    URL newUrl = new URL(location);
View Full Code Here

            else
                return null; // TODO: are other types of connection (https?) relevant?
        } finally {
            try {
                if (in != null) in.close();
                if (huc != null) huc.disconnect();
            } catch (IOException ex) { ex.printStackTrace(); }
        }

    }
View Full Code Here

                spooler_log.info( "Antwort des Web-Dienstes:" );
                spooler_log.info( string_from_reader( new InputStreamReader( http_connection.getInputStream(), encoding ) ) );       
            }
            finally
            {
                if( http_connection != null http_connection.disconnect();
            }
        }

        //-----------------------------------------------------------------------------------------
       
View Full Code Here

            //Object response = http_connection.getContent();
            spooler_log.info( string_from_reader( new InputStreamReader( http_connection.getInputStream(), encoding ) ) );       
        }
        finally
        {
            if( http_connection != null http_connection.disconnect();
        }

        return false;
    }
   
View Full Code Here

            }
          } else if ("http".equals(url.getProtocol())) {
            HttpURLConnection uc = (HttpURLConnection) url.openConnection();
            uc.connect();
            int rc = uc.getResponseCode();
            uc.disconnect();
            if (rc!=HttpURLConnection.HTTP_OK) {
              println("Can't access HTTP bundle: " + url + ", response code=" + rc, 0);
              continue; // Noope; try next.
            }
          } else {
View Full Code Here

      throw new InterruptedRecorderException("Save " + name + " interrupted");
    } catch (IOException ex) {
      throw new RecorderException("Can't save home " + name, ex);
    } finally {
      if (connection != null) {
        connection.disconnect();
      }
    }
  }

  /**
 
View Full Code Here

      if (read != '1') {
        throw new IOException("Saving preferences failed");
      }
    } finally {
      if (connection != null) {
        connection.disconnect();
      }
    }
  }

  /**
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.