diff --git a/src/main/java/com/proculite/FileOperations.java b/src/main/java/com/proculite/FileOperations.java new file mode 100644 index 0000000..814e826 --- /dev/null +++ b/src/main/java/com/proculite/FileOperations.java @@ -0,0 +1,44 @@ +/* +This file is part of Proculite common. + +Proculite common is free software: you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by the +Free Software Foundation, either version 3 of the License, or (at your option) +any later version. + +Proculite common is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with Proculite common. If not, see . + */ +package com.proculite; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +public class FileOperations { + + public static boolean writeTextToFile(String filePath, String text) { + File file = new File(filePath); + if (!file.canWrite()) { + return false; + } + + try { + FileOutputStream fileStream = new FileOutputStream(file); + fileStream.write(text.getBytes(StandardCharsets.UTF_8)); + } catch (FileNotFoundException ex) { + return false; + } catch (IOException ex) { + return false; + } + + return false; + } +}