mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-02 19:47:36 +00:00
ファイルが存在しない場合に作成するメソッドを追加
This commit is contained in:
2 files changed
+17
No files matched your search
@@ -35,6 +35,8 @@ public interface FileManager {
|
||||
// Create
|
||||
FileManager createFile() throws IOException;
|
||||
FileManager createFile(String fileName) throws IOException;
|
||||
FileManager createFileIfNotExist() throws IOException;
|
||||
FileManager createFileIfNotExist(String fileName) throws IOException;
|
||||
FileManager createDirectory() throws IOException;
|
||||
FileManager createDirectory(String directoryName) throws IOException;
|
||||
FileManager createDirectoryIfNotExist() throws IOException;
|
||||
|
||||
@@ -190,6 +190,20 @@ public class FileManagerImpl implements FileManager {
|
||||
return this.createFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileManager createFileIfNotExist() throws IOException {
|
||||
if (!this.isExist()) {
|
||||
this.createFile();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileManager createFileIfNotExist(String fileName) throws IOException {
|
||||
this.resolve(fileName);
|
||||
return this.createFileIfNotExist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileManager createDirectory() throws IOException {
|
||||
try {
|
||||
@@ -237,6 +251,7 @@ public class FileManagerImpl implements FileManager {
|
||||
transformer.transform(source, result);
|
||||
} catch (Exception e) {
|
||||
logger.error("saveXmlInternal", e.getMessage());
|
||||
e.printStackTrace();
|
||||
throw new IOException("Failed to save xml");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user