|
@@ -116,9 +116,10 @@ public class AutoUpdateService {
|
|
|
* 确定执行更新.
|
|
* 确定执行更新.
|
|
|
*/
|
|
*/
|
|
|
public void autoUpdate(ApplicationSetting setting) {
|
|
public void autoUpdate(ApplicationSetting setting) {
|
|
|
|
|
+ //需要更新的文件
|
|
|
List<String> autoUpdateFileNames = setting.getAutoUpdateFileNames();
|
|
List<String> autoUpdateFileNames = setting.getAutoUpdateFileNames();
|
|
|
String savePath = setting.getInstallPath();
|
|
String savePath = setting.getInstallPath();
|
|
|
- //文件保存位置
|
|
|
|
|
|
|
+ //用于保存下载文件的目录
|
|
|
File saveDir = new File(savePath);
|
|
File saveDir = new File(savePath);
|
|
|
String fileName = savePath.substring(savePath.lastIndexOf("\\")+1);
|
|
String fileName = savePath.substring(savePath.lastIndexOf("\\")+1);
|
|
|
URL url;
|
|
URL url;
|
|
@@ -126,6 +127,7 @@ public class AutoUpdateService {
|
|
|
FileOutputStream fos = null;
|
|
FileOutputStream fos = null;
|
|
|
try {
|
|
try {
|
|
|
for (String s : autoUpdateFileNames) {
|
|
for (String s : autoUpdateFileNames) {
|
|
|
|
|
+ //url请求路径
|
|
|
String requestPath = updateSite + "/" + fileName + "/" + s;
|
|
String requestPath = updateSite + "/" + fileName + "/" + s;
|
|
|
if (!existHttpPath(requestPath)) {
|
|
if (!existHttpPath(requestPath)) {
|
|
|
throw new RuntimeException("需要更新的文件"+ requestPath + "不存在");
|
|
throw new RuntimeException("需要更新的文件"+ requestPath + "不存在");
|
|
@@ -138,7 +140,7 @@ public class AutoUpdateService {
|
|
|
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
|
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
|
|
//得到输入流
|
|
//得到输入流
|
|
|
inputStream = conn.getInputStream();
|
|
inputStream = conn.getInputStream();
|
|
|
- //获取自己数组
|
|
|
|
|
|
|
+ //获取自己的输入流数组
|
|
|
byte[] getData = readInputStream(inputStream);
|
|
byte[] getData = readInputStream(inputStream);
|
|
|
|
|
|
|
|
//判断要保存的目录是否存在,不存在就创建
|
|
//判断要保存的目录是否存在,不存在就创建
|
|
@@ -149,6 +151,7 @@ public class AutoUpdateService {
|
|
|
fos = new FileOutputStream(file);
|
|
fos = new FileOutputStream(file);
|
|
|
fos.write(getData);
|
|
fos.write(getData);
|
|
|
if (s.substring(s.lastIndexOf(".")+1).equals("zip")) {
|
|
if (s.substring(s.lastIndexOf(".")+1).equals("zip")) {
|
|
|
|
|
+ //解压改文件file至目录下C:\\Users\\TianGuangHui\\Service\\Report_Server_20171218
|
|
|
unZipFiles(file,"C:\\Users\\TianGuangHui\\Service\\Report_Server_20171218\\");
|
|
unZipFiles(file,"C:\\Users\\TianGuangHui\\Service\\Report_Server_20171218\\");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|