package wtf.beatrice.limbomanager.utils; import wtf.beatrice.limbomanager.LimboManager; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.logging.Level; public class FileUtils { public static void copyFileFromSrc(File destination) { // Check if files already exists and if it doesn't, then create it. if(!destination.exists()) { // Load the InputStream of the file in the source folder. InputStream is = FileUtils.class.getResourceAsStream("/" + destination.getName()); try { // Try copying the file to the directory where it's supposed to be, and log it. Files.copy(is, Paths.get(destination.getAbsolutePath())); is.close(); LimboManager.getInstance().getLogger().log(Level.INFO, "File " + destination.getName() + " successfully created."); } catch (IOException e) { // Throw exception if something went wrong LimboManager.getInstance().getLogger().log(Level.SEVERE, "There were some unexpected errors from " + destination.getName() + " file creation. Please contact the developer and send him this log:"); e.printStackTrace(); } } } }