-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from joon6093/1.2.x
Release v1.2.1
- Loading branch information
Showing
10 changed files
with
204 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.jeyong.handler; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class FileUtils { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); | ||
|
||
private FileUtils() { | ||
} | ||
|
||
public static void writeToFile(final String filePath, final String message) { | ||
if (filePath == null || filePath.isBlank()) { | ||
return; | ||
} | ||
|
||
final File file = new File(filePath); | ||
try { | ||
createParentDirectories(file); | ||
try (FileWriter writer = new FileWriter(file)) { | ||
writer.write(message); | ||
} | ||
} catch (IOException e) { | ||
logger.error("Failed to write to file {}: {}", filePath, e.getMessage()); | ||
} | ||
} | ||
|
||
private static void createParentDirectories(final File file) throws IOException { | ||
final File parentDir = file.getParentFile(); | ||
if (parentDir != null && !parentDir.exists() && !parentDir.mkdirs()) { | ||
throw new IOException("Failed to create parent directories for " + file.getAbsolutePath()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.