Package io.github.astrapi69.file.write
Class StoreFileExtensions
java.lang.Object
io.github.astrapi69.file.write.StoreFileExtensions
The class
StoreFileExtensions
provides extension methods for files to store or update-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Stores the given byte array to the givenFile
objectstatic boolean
static boolean
static boolean
static boolean
toFile
(File file, Collection<String> lines) Writes the given lines in the collection into the given filestatic boolean
toFile
(File file, Collection<String> lines, String encoding) Writes the given lines in the collection into the given filestatic boolean
toFile
(File file, Collection<String> lines, Charset charset) Writes the given lines in the collection into the given file
-
Method Details
-
toFile
Stores the given byte array to the givenFile
object- Parameters:
file
- TheFile
object to write the given byte arraydata
- 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 - Parameters:
file
- TheFile
object to write the givenString
objectstringToWrite
- TheString
object to write into the givenFile
object- Returns:
- true if given
String
object was written successfully to the givenFile
object otherwise false - Throws:
FileNotFoundException
- is thrown if an attempt to open the file denoted by a specified pathname has failedIOException
- Signals that an I/O exception has occurred
-
toFile
Writes the given lines in the collection into the given file- Parameters:
file
- TheFile
object to writelines
- The lines to write to file- Returns:
- true if given
Collection
ofString
objects was written successfully to the givenFile
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
- TheFile
object to writelines
- The lines to write to fileencoding
- The encoding from the file asString
object- Returns:
- true if given
Collection
ofString
objects was written successfully to the givenFile
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
- TheFile
object to writelines
- The lines to write to filecharset
- The charset from the file.- Returns:
- true if given
Collection
ofString
objects was written successfully to the givenFile
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 givenString
object to the givenFile
object with the given encoding asString
object- Parameters:
file
- TheFile
object to write the givenString
objectstringToWrite
- TheString
object to write into the givenFile
objectencoding
- The encoding from the file asString
object- Returns:
- true if given
String
object was written successfully to the givenFile
object otherwise false - Throws:
FileNotFoundException
- is thrown if an attempt to open the file denoted by a specified pathname has failedIOException
- 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 givenString
object to the givenFile
object with the encoding that is encapsulated in the givenCharset
object- Parameters:
file
- TheFile
object to write the givenString
objectstringToWrite
- TheString
object to write into the givenFile
objectcharset
- The charset from the file.- Returns:
- true if given
String
object was written successfully to the givenFile
object otherwise false - Throws:
FileNotFoundException
- is thrown if an attempt to open the file denoted by a specified pathname has failedIOException
- Signals that an I/O exception has occurred
-