1 Reply Latest reply: Mar 5, 2007 9:16 AM by 807597 RSS

    Unknownhostexception during the download

    807597
      hi,
      I am trying to download a data by the following code, but it generates Unknownhostexception: www.anysite.com
       
      try
              {
                  URLConnection urlConn = url.openConnection();
                  urlConn.connect();
                  in = urlConn.getInputStream();
                  _f = new File(_saveto);
                  buff  = new BufferedInputStream(in);
                  file  = new FileOutputStream(_f);
                  out = new BufferedOutputStream(file);
                  int i;
                  while ( (i = in.read()) != -1) {
                    compl += i;
                    out.write(i);
                  }
                  out.flush();
                  out.close();
      
                  contLen = urlConn.getContentLength();
              }
              catch(MalformedURLException me){
                me.printStackTrace();
              }
              catch(IOException e)
              {
                  e.printStackTrace();
                  
              }
      how to resolve this problem?
      Thanks