Example #1
0
 /**
  * @param Codebase String
  * @param hashList Hashtable
  * @param US UpdateStub
  * @return Object
  */
 private static Object downloadFile(String Codebase, Hashtable hashList, UpdateStub US) {
   int size = US.getInt("remotesize", 0);
   String LocalFileName = getLocalFileURI(hashList, US);
   String RemoteFileName = getRemoteFileURI(Codebase, US);
   File file = getLocalFile(LocalFileName);
   URL url = getRemoteFileURL(RemoteFileName);
   BasicNetworkLayer basicLayer = new BasicNetworkLayer();
   BasicDownloadLayer downloadFile = new BasicDownloadLayer(basicLayer);
   try {
     System.out.print("downloading:" + url.toString());
     downloadFile.download(url, file, null);
     file.setLastModified(Long.parseLong(US.getRemoteTime()));
     System.out.println(" is finish!");
   } catch (Exception e) {
     System.out.println("downloading:" + url.toString() + " is error!");
     file.delete();
     e.printStackTrace();
     if (e.getMessage() == null) {
       return e.getCause();
     }
     return e;
     //      e.printStackTrace();
   }
   return null;
   //    for(int i=0;i<size;i++) {
   //      pnSecond.setValue(i+1);
   //      this.lbTitle3.setText(US.toString()+" "+ String.valueOf(i+1)+"/"+String.valueOf(size));
   //    }
 }
Example #2
0
 /**
  * @param hashList Map
  * @param US UpdateStub
  * @return String
  */
 private static String getLocalFileURI(java.util.Map hashList, UpdateStub US) {
   String FileName = null;
   String PathName = (String) hashList.get("user.home");
   String Separator = System.getProperty("file.separator");
   PathName =
       PathName + UpdateObject.getCodeSpace() + Separator + US.getStubPathName(false) + Separator;
   File dirFile = new File(PathName);
   if (!dirFile.exists()) {
     dirFile.mkdirs();
   }
   FileName = PathName + US.getStubFileName();
   return FileName;
 }
Example #3
0
 /**
  * @param Codebase String
  * @param US UpdateStub
  * @return String
  */
 private static String getRemoteFileURI(String Codebase, UpdateStub US) {
   String PathName = null;
   if (Codebase.toLowerCase().startsWith("file")) {
     PathName = Codebase + US.getStubPathName(true) + US.getStubFileName();
   } else {
     if (US.getString("svr", null) == null) { // add by fsz
       PathName =
           Codebase
               + UpdateObject.CODE_SPACE
               + "/"
               + US.getStubPathName(true)
               + US.getStubFileName();
     } else {
       //        PathName =US.getString("svr","")+US.getString("urlpath","")+US.getStubFileName();
       PathName =
           US.getString("svr", "")
               + UpdateObject.CODE_SPACE
               + "/"
               + US.getStubPathName(true)
               + US.getStubFileName();
     }
   }
   return PathName;
 }