Class StoreFileExtensions

java.lang.Object
io.github.astrapi69.file.write.StoreFileExtensions

public final class StoreFileExtensions extends Object
The class StoreFileExtensions provides extension methods for files to store or update
  • Method Details

    • toFile

      public static void toFile(File file, byte[] data) throws IOException
      Stores the given byte array to the given File object
      Parameters:
      file - The File object to write the given byte array
      data - The byte array to be store
      Throws:
      IOException - Signals that an I/O exception has occurred
    • toFile

      public static boolean toFile(File file, String stringToWrite) throws FileNotFoundException, IOException
      This Method writes the given String object to the given File object
      Parameters:
      file - The File object to write the given String object
      stringToWrite - The String object to write into the given File object
      Returns:
      true if given String object was written successfully to the given File object otherwise false
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed
      IOException - Signals that an I/O exception has occurred
    • toFile

      public static boolean toFile(File file, Collection<String> lines) throws IOException
      Writes the given lines in the collection into the given file
      Parameters:
      file - The File object to write
      lines - The lines to write to file
      Returns:
      true if given Collection of String objects was written successfully to the given File object otherwise false
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • toFile

      public static boolean toFile(File file, Collection<String> lines, String encoding) throws IOException
      Writes the given lines in the collection into the given file
      Parameters:
      file - The File object to write
      lines - The lines to write to file
      encoding - The encoding from the file as String object
      Returns:
      true if given Collection of String objects was written successfully to the given File object otherwise false
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • toFile

      public static boolean toFile(File file, Collection<String> lines, Charset charset) throws IOException
      Writes the given lines in the collection into the given file
      Parameters:
      file - The File object to write
      lines - The lines to write to file
      charset - The charset from the file.
      Returns:
      true if given Collection of String objects was written successfully to the given File object otherwise false
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • toFile

      public static boolean toFile(File file, String stringToWrite, String encoding) throws FileNotFoundException, IOException
      This Method writes the given String object to the given File object with the given encoding as String object
      Parameters:
      file - The File object to write the given String object
      stringToWrite - The String object to write into the given File object
      encoding - The encoding from the file as String object
      Returns:
      true if given String object was written successfully to the given File object otherwise false
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed
      IOException - Signals that an I/O exception has occurred
    • toFile

      public static boolean toFile(File file, String stringToWrite, Charset charset) throws FileNotFoundException, IOException
      This Method writes the given String object to the given File object with the encoding that is encapsulated in the given Charset object
      Parameters:
      file - The File object to write the given String object
      stringToWrite - The String object to write into the given File object
      charset - The charset from the file.
      Returns:
      true if given String object was written successfully to the given File object otherwise false
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed
      IOException - Signals that an I/O exception has occurred