Package java.net

Examples of java.net.URL.openConnection()


      try {
    String resourceName = toResourceName(toBundleName(baseName, locale), format);
    URL url = loader.getResource(resourceName);
    if (url != null) {
        long lastModified = 0;
        URLConnection connection = url.openConnection();
        if (connection != null) {
      // disable caches to get the correct data
      connection.setUseCaches(false);
      if (connection instanceof JarURLConnection) {
          JarEntry ent = ((JarURLConnection)connection).getJarEntry();
View Full Code Here


        InputStream is = null;
        BufferedReader br = null;
        try
        {
            // Open the URL and read to our specified line
            URLConnection uc = url.openConnection();
            is = uc.getInputStream();
            br = new BufferedReader(new InputStreamReader(is));

            // Not the most efficient way, but it works
            // (Feel free to patch to seek to the appropriate line)
View Full Code Here

  Permission p;
  URLConnection urlConnection;

  try {
      urlConnection = url.openConnection();
      p = urlConnection.getPermission();
  } catch (java.io.IOException ioe) {
      p = null;
      urlConnection = null;
  }
View Full Code Here

            }

            // got url, open it
            URLConnection urlConnection = null;
            try {
                urlConnection = url.openConnection();
            } catch (IOException e) {
                throw new IllegalStateException("Cannot open connection on the URL '" + url + "'.", e);
            }
            urlConnection.setDefaultUseCaches(false);
View Full Code Here

          url = new URL(newUrlStr);
        }
      }
    }
   
    conn = url.openConnection();
   
    // TODO: why does Java do this with relative file URLs, like file://samplemedia/safexmas.mov
    // it turns this into ftp://samplemedia/safexmas.mov
    // very strange.
    // typically sun.net.www.protocol.ftp.FtpURLConnection
View Full Code Here

        BufferedReader rd;
        String line;
        StringBuilder result = new StringBuilder();
        try {
           url = new URL(urlToRead);
           conn = (HttpURLConnection) url.openConnection();
           conn.setRequestMethod("GET");
           rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
           while ((line = rd.readLine()) != null) {
              result.append(line);
           }
View Full Code Here

  /* check if there is a Tomcat connection to the server */
  private static boolean isServerStarted(String host) throws MalformedURLException {
    // URL to Tomcat
    URL url = new URL("http", host, 8080, "/") ;
    try {
      URLConnection conn = url.openConnection() ;
      if (conn instanceof HttpURLConnection) {
        HttpURLConnection http = (HttpURLConnection) conn ;
        int responseCode = http.getResponseCode();
       
        if (responseCode > 0 && responseCode < 400) {
View Full Code Here

                .getType("article"));
            entry.setField("citeseerurl", id);

            try {
                URL citeseerUrl = new URL(OAI_URL + id);
                HttpURLConnection citeseerConnection = (HttpURLConnection) citeseerUrl
                    .openConnection();
                InputStream inputStream = citeseerConnection.getInputStream();

                DefaultHandler handlerBase = new CiteSeerEntryFetcherHandler(entry);
View Full Code Here

    {
      LoginState state = null;
    String url = this.buildUrl(user, img);
    try {
          URL doUrl = new URL(url);
          HttpsURLConnection conn = (HttpsURLConnection) doUrl.openConnection();
          int status = conn.getResponseCode();
          logger.debug("SSISignV4:status="+status);
         
          switch(status){
         
View Full Code Here

            }
      System.out.println(url);
      try {
              URL trueURL = new URL(url);
              logger.info("Sending crush report...");
              HttpURLConnection conn = (HttpURLConnection) trueURL.openConnection();
              if(conn.getResponseCode()==200) {
                logger.info("Send crush report OK.");
              }else {
                logger.info("Send crush report Failed. status="+conn.getResponseCode()+" "+conn.getResponseMessage());
              }
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.