Java File Append appendFile(OutputStream output, File source)

Here you can find the source of appendFile(OutputStream output, File source)

Description

append File

License

Open Source License

Declaration

private static void appendFile(OutputStream output, File source) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedInputStream;

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    private static void appendFile(OutputStream output, File source) throws IOException {
        InputStream input = null;
        try {//from  w ww .j a  v  a 2 s.  c  o  m
            input = new BufferedInputStream(new FileInputStream(source));

            byte[] buf = new byte[1024];
            int len;
            while ((len = input.read(buf)) > 0) {
                output.write(buf, 0, len);
            }
        } finally {
            input.close();
        }
    }
}

Related

  1. appendFile(File targetFile, String text)
  2. appendFile(File targetFile, String toWrite)
  3. appendFile(final File srcFile, final File destFile)
  4. appendFile(final String filename, final String content)
  5. appendFile(final String name, final String s)
  6. appendFile(String content, File file)
  7. appendFile(String file, byte[]... data)
  8. appendFile(String file, String content)
  9. appendFile(String file, String text)