Compare commits
3 commits
bb8713049b
...
492e461307
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
492e461307 | ||
|
|
de18e4bd9f | ||
|
|
23c621784c |
3
pom.xml
3
pom.xml
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ import java.nio.charset.StandardCharsets;
|
|||
public class FileOperations {
|
||||
|
||||
public static boolean writeTextToFile(String filePath, String text) {
|
||||
return writeBytesToFile(filePath, text.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public static boolean writeBytesToFile(String filePath, byte[] bytes) {
|
||||
File file = new File(filePath);
|
||||
if (!file.canWrite()) {
|
||||
return false;
|
||||
|
|
@ -32,11 +36,12 @@ public class FileOperations {
|
|||
|
||||
try {
|
||||
FileOutputStream fileStream = new FileOutputStream(file);
|
||||
fileStream.write(text.getBytes(StandardCharsets.UTF_8));
|
||||
fileStream.write(bytes);
|
||||
return true;
|
||||
} catch (FileNotFoundException ex) {
|
||||
return false;
|
||||
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue