java.lang.Object
io.github.astrapi69.file.write.WriteFileExtensions
The class
WriteFileExtensions
provides methods for writing in files.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
readSourceFileAndWriteDestFile
(String srcfile, String destFile) Writes the source file with the best performance to the destination file.static void
string2File
(String string2write, String nameOfFile) The Method string2File() writes a String to the file.static void
write
(InputStream inputStream, OutputStream outputStream) Writes the given input stream to the output stream.static void
write2File
(Reader reader, Writer writer) The Method write2File() reads from an opened Reader and writes it to the opened Writer.static void
write2File
(String inputFile, Writer writer) The Method write2File() writes the File into the PrintWriter.static void
write2File
(String inputFile, String outputFile) The Method write2File(String, String) copys a file from one filename to another.static void
write2FileWithBuffer
(String inputFile, String outputFile) The Method write2FileWithBuffer() copy the content from one file to another.static void
writeByteArrayToFile
(File file, byte[] byteArray) Writes the given byte array to the given file.static void
writeByteArrayToFile
(String filename, byte[] byteArray) Writes the given byte array to a file.static void
writeLinesToFile
(File output, List<String> input, String encoding) Writes the input from the collection into the file.static void
writeLinesToFile
(Collection<String> lines, File output) Writes the input from the lines into the file.static void
writeLinesToFile
(Collection<String> lines, File output, String encoding) Writes the input from the lines into the file.static void
writeProperties2File
(String filename, Properties properties) The Method writeProperties2File(String, Properties) writes the Properties to the file.
-
Method Details
-
readSourceFileAndWriteDestFile
public static void readSourceFileAndWriteDestFile(String srcfile, String destFile) throws IOException Writes the source file with the best performance to the destination file.- Parameters:
srcfile
- The source file.destFile
- The destination file.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
string2File
The Method string2File() writes a String to the file.- Parameters:
string2write
- The String to write into the file.nameOfFile
- The path to the file and name from the file from where we want to write the String.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write
public static void write(InputStream inputStream, OutputStream outputStream) throws FileNotFoundException, IOException Writes the given input stream to the output stream.- Parameters:
inputStream
- the input streamoutputStream
- the output stream- Throws:
FileNotFoundException
- is thrown if the given file is not foundIOException
- Signals that an I/O exception has occurred.
-
write2File
The Method write2File() reads from an opened Reader and writes it to the opened Writer.- Parameters:
reader
- The opened Reader.writer
- The opened Writer.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write2File
The Method write2File(String, String) copys a file from one filename to another.- Parameters:
inputFile
- The Name from the File to read and copy.outputFile
- The Name from the File to write into.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
write2File
public static void write2File(String inputFile, Writer writer) throws FileNotFoundException, IOException The Method write2File() writes the File into the PrintWriter.- Parameters:
inputFile
- The Name from the File to read and copy.writer
- The PrintWriter to write into.- 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.
-
write2FileWithBuffer
public static void write2FileWithBuffer(String inputFile, String outputFile) throws FileNotFoundException, IOException The Method write2FileWithBuffer() copy the content from one file to another. It use a buffer as the name says.- Parameters:
inputFile
- The Path to the File and name from the file from where we read.outputFile
- The Path to the File and name from the file from where we want to write.- 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.
-
writeByteArrayToFile
Writes the given byte array to the given file.- Parameters:
file
- The file.byteArray
- The byte array.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeByteArrayToFile
Writes the given byte array to a file.- Parameters:
filename
- The filename from the file.byteArray
- The byte array.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeLinesToFile
public static void writeLinesToFile(Collection<String> lines, File output) throws FileNotFoundException, IOException Writes the input from the lines into the file.- Parameters:
lines
- The lines to write to file.output
- The output-file.- 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.
-
writeLinesToFile
public static void writeLinesToFile(Collection<String> lines, File output, String encoding) throws FileNotFoundException, IOException Writes the input from the lines into the file.- Parameters:
lines
- The lines to write to file.output
- The output-file.encoding
- the encoding- 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.
-
writeLinesToFile
public static void writeLinesToFile(File output, List<String> input, String encoding) throws FileNotFoundException, IOException Writes the input from the collection into the file.- Parameters:
output
- The file to write the lines.input
- The list with the input data.encoding
- The encoding.- 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.
-
writeProperties2File
The Method writeProperties2File(String, Properties) writes the Properties to the file.- Parameters:
filename
- The filename from the file to write the properties.properties
- The properties.- Throws:
IOException
- Signals that an I/O exception has occurred.
-