【修改】 删除创建隐藏应用文件,导致文件第二次无法写入
This commit is contained in:
@@ -53,24 +53,13 @@ public class LogFileUtils {
|
|||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对于Unix系统,直接在文件名前加"."
|
|
||||||
if (!System.getProperty("os.name").toLowerCase().contains("win")) {
|
|
||||||
String hiddenPath = file.getParent() + File.separator + "." + file.getName();
|
|
||||||
file = new File(hiddenPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建文件(如果不存在)
|
// 创建文件(如果不存在)
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对于Windows系统,设置隐藏属性
|
|
||||||
if (System.getProperty("os.name").toLowerCase().contains("win")) {
|
|
||||||
Runtime.getRuntime().exec("attrib +H " + file.getCanonicalPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("无法创建隐藏文件: " + e.getMessage(), e);
|
throw new RuntimeException("无法创建文件: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user