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

voidsave(byte[] bytes, File path)
save
if (bytes != null) {
    FileOutputStream fos = new FileOutputStream(path);
    fos.write(bytes);
    fos.close();
voidsave(byte[] data, String path)
save
File f = new File(path);
File p = f.getParentFile();
if ((p != null) && (!p.isDirectory())) {
    p.mkdirs();
FileOutputStream fout = new FileOutputStream(f);
fout.write(data);
fout.close();
...
voidsave(File file, byte[] bytes)
Saves a byte array to a file.
OutputStream os = new FileOutputStream(file);
try {
    os = new BufferedOutputStream(os);
    for (int i = 0; i < bytes.length; i += 2048) {
        int len = Math.min(bytes.length - i, 2048);
        os.write(bytes, i, len);
} finally {
...
voidsave(File file, byte[] content)
save
FileOutputStream out = new FileOutputStream(file);
save(out, content);
out.close();
voidsave(File file, byte[] content)
save
FileOutputStream out = new FileOutputStream(file);
try {
    out.write(content);
} finally {
    out.close();
voidsave(File file, final byte[] encoded)
save
file = expandFilepath(file);
File parent = file.getParentFile();
if (parent != null && parent.exists() == false) {
    parent.mkdirs();
FileOutputStream out = new FileOutputStream(file);
try {
    out.write(encoded);
...
voidsave(final InputStream in, final File file)
Saves the contents of an InputStream in a file.
file.getParentFile().mkdirs();
FileOutputStream out = null;
try {
    out = new FileOutputStream(file);
    final byte[] buffer = new byte[16 * 1024];
    int read;
    while ((read = in.read(buffer)) > 0) {
        out.write(buffer, 0, read);
...
voidsave(InputStream in, File f)
save
FileOutputStream out = new FileOutputStream(f);
try {
    byte[] buffer = new byte[4 * 1024];
    int len = 0;
    while ((len = in.read(buffer)) != -1) {
        out.write(buffer, 0, len);
} finally {
...
voidsave(String content, String fileName)
save
File file = new File(fileName);
OutputStream out = new FileOutputStream(file);
out.write(content.getBytes("UTF-8"));
out.flush();
out.close();
voidsave(String data, String encoding, String file)
save
FileOutputStream os = new FileOutputStream(file);
byte[] buf = data.getBytes(encoding);
os.write(buf);
os.close();