|
|
@@ -1,7 +1,9 @@
|
|
|
package com.leanwo.management.util;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
import java.io.Closeable;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -52,7 +54,12 @@ public class FileUtil {
|
|
|
if(!stopFile.exists()) {
|
|
|
continue;
|
|
|
}
|
|
|
- applicationSetting.setName(f.getName());
|
|
|
+ String name = readFileContent(runFile);
|
|
|
+ name = name.replace("::", "").replace(" ", "").replace("echo", "").replace("title", "");
|
|
|
+ if(name == null || name.length() <= 0) {
|
|
|
+ name = f.getName();
|
|
|
+ }
|
|
|
+ applicationSetting.setName(name);
|
|
|
applicationSetting.setInstallPath(filePath);
|
|
|
applicationSetting.setStartBatFile("run.bat");
|
|
|
applicationSetting.setStopBatFile("stop.bat");
|
|
|
@@ -63,4 +70,29 @@ public class FileUtil {
|
|
|
return settings;
|
|
|
}
|
|
|
|
|
|
+ public static String readFileContent(File file) {
|
|
|
+ BufferedReader reader = null;
|
|
|
+ StringBuffer sbf = new StringBuffer();
|
|
|
+ try {
|
|
|
+ reader = new BufferedReader(new FileReader(file));
|
|
|
+ String tempStr = reader.readLine();
|
|
|
+ sbf.append(tempStr);
|
|
|
+// while ((tempStr = reader.readLine()) != null) {
|
|
|
+// sbf.append(tempStr);
|
|
|
+// }
|
|
|
+ reader.close();
|
|
|
+ return sbf.toString();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (reader != null) {
|
|
|
+ try {
|
|
|
+ reader.close();
|
|
|
+ } catch (IOException e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sbf.toString();
|
|
|
+ }
|
|
|
}
|