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