Java Utililty Methods FileOutputStream Create

List of utility methods to do FileOutputStream Create

Description

The list of methods to do FileOutputStream Create are organized into topic(s).

Method

OutputStreamgetOutputStream(File file)
get Output Stream
return getOutputStream(file, false);
OutputStreamgetOutputStream(File file)
get Output Stream
assert file != null;
OutputStream out = null;
try {
    out = new FileOutputStream(file);
} catch (FileNotFoundException e) {
    System.err.println("Can't find file " + file);
    e.printStackTrace();
return out;
OutputStreamgetOutputStream(File file, String filePath)
get Output Stream
try {
    return new FileOutputStream(filePath + "/" + file.getName());
} catch (FileNotFoundException e) {
    e.printStackTrace();
return null;
FileOutputStreamgetOutputStream(final File file)
get Output Stream
try {
    return new FileOutputStream(file);
} catch (FileNotFoundException e) {
    return null;
OutputStreamgetOutputStream(final File file)
Gets the output stream from a File object.
return getOutputStream(file, false);
OutputStreamgetOutputStream(final Object obj, final boolean append)
Turn an object into an OutputStream if possible.
OutputStream stream = null;
if (obj instanceof OutputStream) {
    stream = (OutputStream) obj;
} else if (obj instanceof File) {
    File file = (File) obj;
    File parent = file.getAbsoluteFile().getParentFile();
    if (!parent.exists()) {
        if (!parent.mkdirs()) {
...
DataOutputStreamgetOutputStream(String file)
Return a buffered output stream stream for file.
return getOutputStream(new File(file));
OutputStreamgetOutputStream(String filename)
Gets an output stream
OutputStream os = null;
try {
    File f = new File(filename);
    os = new FileOutputStream(f);
} catch (Exception e) {
    try {
        os.close();
    } catch (Exception ex) {
...
BufferedOutputStreamgetOutputStream(String fileName)
get Output Stream
return getOutputStream(new File(fileName));
OutputStreamgetOutputStream(String filename, Map map)
Returns the OutputStream contained in the map , if present, or creates a new OutputStream attached to the specified file.
if (map != null && map.containsKey(filename)) {
    return map.get(filename);
} else {
    return new FileOutputStream(filename);