修改开机自启文件复制逻辑
This commit is contained in:
parent
fe3731d613
commit
2cdefbd8b9
|
@ -31,9 +31,27 @@ public class AutoStartFile {
|
|||
|
||||
private static void generate() {
|
||||
try {
|
||||
if (new File(START_UP_FILE_PATH).exists()) {
|
||||
|
||||
StringJoiner fileContentJoiner = new StringJoiner("\n");
|
||||
String driveLetter = AUTO_START_EXEC_FILE_PATH.substring(0, 2);
|
||||
fileContentJoiner.add("@echo off");
|
||||
fileContentJoiner.add(driveLetter);
|
||||
fileContentJoiner.add("cd " + ResourceUtils.getResourceByProject(""));
|
||||
fileContentJoiner.add("RoomIt");
|
||||
String fileContent = fileContentJoiner.toString();
|
||||
|
||||
File startUpFile = new File(START_UP_FILE_PATH);
|
||||
|
||||
if (startUpFile.exists()) {
|
||||
FileInputStream is = new FileInputStream(startUpFile);
|
||||
boolean isSame = new String(is.readAllBytes()).equals(fileContent);
|
||||
|
||||
is.close();
|
||||
|
||||
if (isSame) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(BAT_FILE_PATH);
|
||||
|
||||
|
@ -43,12 +61,6 @@ public class AutoStartFile {
|
|||
|
||||
FileWriter fos = new FileWriter(file);
|
||||
|
||||
StringJoiner fileContentJoiner = new StringJoiner("\n");
|
||||
String driveLetter = AUTO_START_EXEC_FILE_PATH.substring(0, 2);
|
||||
fileContentJoiner.add("@echo off");
|
||||
fileContentJoiner.add(driveLetter);
|
||||
fileContentJoiner.add("cd " + ResourceUtils.getResourceByProject(""));
|
||||
fileContentJoiner.add("RoomIt");
|
||||
|
||||
fos.write(fileContentJoiner.toString());
|
||||
fos.flush();
|
||||
|
|
Loading…
Reference in New Issue