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