update.java
来自「java 开发的sip软电话 源码 jain sip」· Java 代码 · 共 53 行
JAVA
53 行
package net.java.mais.update;
import java.io.File;
import net.java.mais.update.PropertiesDepot;
public class Update {
public static void main(String args[]){
// UpdateManager um = new UpdateManager();
// System.out.println("COPY");
if(update()){
PropertiesDepot.loadProperties();
PropertiesDepot.setProperty("net.java.mais.update.VERSION",PropertiesDepot.getProperty("net.java.mais.update.VERSION_UPDATE"));
PropertiesDepot.storeProperties();
}
softPhone.SoftPhonePlugin.main(args);
}
public static boolean update(){
File updateDir = new File(System.getProperty("EXEPATH")+File.separator+"update"+File.separator);
if(!updateDir.exists()) return false;
//if(PropertiesDepot.getProperty("net.java.mais.update.VERSION").equals(PropertiesDepot.getProperty("net.java.mais.update.VERSION_UPDATE"))) return false;
String[] children = updateDir.list();
File file,dir,old;
boolean updated = true;
boolean success=false;
if (children == null) {
// Either dir does not exist or is not a directory
return false;
} else {
for (int i=0; i<children.length; i++) {
file = new File(System.getProperty("EXEPATH")+File.separator+"update"+File.separator+children[i]);
if(file.isFile()&&file.length()>500){
// Destination directory
dir = new File(System.getProperty("EXEPATH")+File.separator+"lib"+File.separator);
// Delete old
old = new File(System.getProperty("EXEPATH")+File.separator+"lib"+File.separator+children[i]);
old.delete();
// Move file to new directory
success=file.renameTo(new File(dir, file.getName()));
updated= updated && success;
System.out.println(children[i]+" updated ["+success+"]");
}else if(file.length()<500){
file.delete();
}
}
updateDir.delete();
}
return updated;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?