Java Utililty Methods File to OutputStream

List of utility methods to do File to OutputStream

Description

The list of methods to do File to OutputStream are organized into topic(s).

Method

OutputStreamnewOutputStream()
new Output Stream
return new ByteArrayOutputStream();
voidnewOutputStream()
new Output Stream
byteArrayOS = new ByteArrayOutputStream();
dataOS = new DataOutputStream(byteArrayOS);
OutputStreamnewOutputStream(File file)
new Output Stream
return newFileOutputStream(file);
OutputStreamnewOutputStream(File file)
new Output Stream
try {
    if (!file.exists()) {
        file.getParentFile().mkdirs();
        file.createNewFile();
    return new BufferedOutputStream(new FileOutputStream(file));
} catch (IOException e) {
    throw new RuntimeException(e);
...
OutputStreamopenOutputStream(File file)
open Output Stream
return new FileOutputStream(file);
FileOutputStreamopenOutputStream(File file)
open Output Stream
FileOutputStream stream = new FileOutputStream(file);
return stream;
FileOutputStreamopenOutputStream(File file)
open Output Stream
if (file.exists()) {
    if (file.isDirectory()) {
        throw new IOException("File '" + file + "' exists but is a directory");
    if (!file.canWrite()) {
        throw new IOException("File '" + file + "' can not be written to");
} else {
...
FileOutputStreamopenOutputStream(File file)
Opens a FileOutputStream for the specified file, checking and creating the parent directory if net does not exist.
if (file.exists()) {
    if (file.isDirectory()) {
        throw new IOException("File '" + file + "' exists but is a directory");
    if (file.canWrite() == false) {
        throw new IOException("File '" + file + "' cannot be written to");
} else {
...
OutputStreamopenOutputStream(File file, boolean append, boolean gzip)
open Output Stream
if (file.exists()) {
    if (file.isDirectory()) {
        throw new IOException("File '" + file + "' exists but is a directory");
    if (!file.canWrite()) {
        throw new IOException("File '" + file + "' cannot be written to");
} else {
...
OutputStreamopenOutputStream(File file, int bufferSize)
Opens an OutputStream on a file for writing.
return openOutputStream(file, false, bufferSize);