mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
ファイルが存在しない場合に作成するメソッドを追加
This commit is contained in:
parent
4cf3ff5f3c
commit
8913f8118d
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user