Java Utililty Methods FileOutputStream Write

List of utility methods to do FileOutputStream Write

Description

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

Method

voidsaveBytes(byte[] bytes, File file)
Saves binary data to a file.
OutputStream out = new FileOutputStream(file);
try {
    out.write(bytes, 0, bytes.length);
    out.flush();
} finally {
    out.close();
voidsaveBytes(File f, byte[] content)
save Bytes
FileOutputStream os = null;
ByteArrayInputStream bais = null;
try {
    os = new FileOutputStream(f);
    bais = new ByteArrayInputStream(content);
    byte[] buf = new byte[BUF_SIZE];
    while (true) {
        int rc = bais.read(buf);
...
voidsaveBytes(File file, byte[] bytes)
save Bytes
FileOutputStream outputs = null;
if (bytes == null)
    throw new NullPointerException("Cannot save null as file.");
try {
    outputs = new FileOutputStream(file);
    outputs.write(bytes);
    outputs.close();
} catch (IOException t) {
...
voidsaveBytes(String filename, byte[] byteData)
save Bytes
try {
    createPath(filename);
    FileOutputStream fileOutputStream = new FileOutputStream(filename);
    fileOutputStream.write(byteData);
    fileOutputStream.close();
} catch (Exception e) {
    System.err.println("### ERROR @ Util / problem writing data. " + e.toString());
voidsaveBytes(String filename, byte[] bytes)
save Bytes
try {
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(filename)));
    out.write(bytes);
    out.close();
} catch (Exception exception) {
    exception.printStackTrace();
voidsaveBytes(String filename, byte[] data)
Saves data to the file specified by filename.
FileOutputStream fo = null;
try {
    fo = new FileOutputStream(filename);
    fo.write(data);
} finally {
    closeStream(fo);
voidsaveBytes(String filename, byte[] data)
( begin auto-generated from saveBytes.xml ) Opposite of loadBytes(), will write an entire array of bytes to a file.
saveBytes(saveFile(filename), data);
voidsaveBytesToFile(byte[] bytes, File file)
save Bytes To File
if (file.exists()) {
    file.delete();
if (bytes == null || bytes.length == 0) {
    return;
try {
    file.createNewFile();
...
voidsaveBytesToFile(byte[] bytes, File file)
Used for testing only if we need to open the PDF itself
final FileOutputStream outputStream = new FileOutputStream(file);
outputStream.write(bytes);
outputStream.close();
System.out.println("PDF dumped to " + file.getAbsolutePath() + " by the following calls:");
dumpCurrentStackTrace(System.out);
voidsaveBytesToFile(byte[] data, File file)
save to file
if (data == null) {
    return;
FileOutputStream fos = null;
BufferedOutputStream bos = null;
try {
    fos = new FileOutputStream(file);
    bos = new BufferedOutputStream(fos);
...