ファイルにStringを保存するメソッド作成 WIP

This commit is contained in:
r-ca 2024-01-08 11:54:13 +09:00
parent 2ba243ea4a
commit 15d454690e
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 15 additions and 1 deletions

View File

@ -29,6 +29,9 @@ public interface FileManager {
String loadText(String fileName);
String loadText(Path path);
void saveText(String text, String fileName);
void saveText(String text, Path path);
boolean isExist(Path path);
boolean isExist(String fileName);

View File

@ -151,7 +151,7 @@ public class FileManagerImpl implements FileManager {
}
@Override
public String loadText(String fileName) {
public String loadText(String fileName) { // TODO-rca: 統合
try(FileInputStream fileInputStream = new FileInputStream(currentDir.resolve(fileName).toFile())) {
byte[] bytes = new byte[fileInputStream.available()];
fileInputStream.read(bytes); // TODO-rca: エラーハンドリング
@ -174,6 +174,17 @@ public class FileManagerImpl implements FileManager {
}
}
@Override
public void saveText(String text, String fileName) {
createFile(fileName);
}
@Override
public void saveText(String text, Path path) {
}
@Override
public boolean isExist(Path path) {
logger.debug("isExist", "called");