Java Utililty Methods BufferedInputStream Copy

List of utility methods to do BufferedInputStream Copy

Description

The list of methods to do BufferedInputStream Copy are organized into topic(s).

Method

voidcopyFile(File file, File ziel)
copy File
in = new BufferedInputStream(new FileInputStream(file));
out = new BufferedOutputStream(new FileOutputStream(ziel, true));
int bytes = 0;
while ((bytes = in.read()) != -1) {
    out.write(bytes);
in.close();
out.close();
...
voidcopyFile(File from, File to)
copy File
createFileSafely(to);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(from));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(to));
byte[] block;
while (bis.available() > 0) {
    block = new byte[16384];
    final int readNow = bis.read(block);
    bos.write(block, 0, readNow);
...
voidcopyFile(File from, File to)
copy File
int bytes;
long length;
long fileSize;
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
    in = new BufferedInputStream(new FileInputStream(from));
} catch (IOException ex) {
...
voidcopyFile(File from, File to)
copy File
InputStream in = null;
OutputStream out = null;
try {
    in = new FileInputStream(from);
} catch (IOException ex) {
    throw new IOException(
            "Utilities.copyFile: opening input stream '" + from.getPath() + "', " + ex.getMessage());
try {
    out = new FileOutputStream(to);
} catch (Exception ex) {
    try {
        in.close();
    } catch (IOException ex1) {
    throw new IOException(
            "Utilities.copyFile: opening output stream '" + to.getPath() + "', " + ex.getMessage());
copyInputToOutput(in, out, from.length());
voidcopyFile(File from, File to)
Copy a file from one location to the next.
InputStream in = null;
OutputStream out = null;
try {
    in = new BufferedInputStream(new FileInputStream(from));
    out = new BufferedOutputStream(new FileOutputStream(to));
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
...
voidcopyFile(File fromFile, File toFile)
Copies a file to another file.
toFile.getParentFile().mkdirs();
BufferedInputStream bufin = null;
FileOutputStream fos = null;
try {
    bufin = new BufferedInputStream(new FileInputStream(fromFile));
    fos = new FileOutputStream(toFile);
    int len = 8196;
    byte[] buff = new byte[len];
...
voidcopyFile(File fSrcFile, File fDestFile)
Copies the file contents from one file to another.
if (fDestFile.isDirectory()) {
    fDestFile = new File(fDestFile, fSrcFile.getName());
File fParent = fDestFile.getParentFile();
if (!fParent.exists()) {
    if (!fParent.mkdirs()) {
        throw new IOException("Unable to create parent folder: " + fParent);
InputStream in = null;
OutputStream out = null;
final int iCopyBufferSize = 32768;
boolean bSuccess = false;
try {
    in = new BufferedInputStream(new FileInputStream(fSrcFile));
    out = new BufferedOutputStream(new FileOutputStream(fDestFile));
    byte[] baBuffer = new byte[iCopyBufferSize];
    int iReadCount;
    while ((iReadCount = in.read(baBuffer)) > 0) {
        out.write(baBuffer, 0, iReadCount);
    bSuccess = true;
    baBuffer = null;
} finally {
    closeStream(in);
    closeStream(out);
    if (!bSuccess && fDestFile.exists()) {
        fDestFile.delete();
voidcopyFile(File in, File out)
copy File
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
    bis = new BufferedInputStream(new FileInputStream(in));
    bos = new BufferedOutputStream(new FileOutputStream(out));
    int available = bis.available();
    available = available <= 0 ? DEFAULT_BUFFER_SIZE : available;
    int chunkSize = Math.min(DEFAULT_BUFFER_SIZE, available);
...
booleancopyFile(File in, File out)
copy File
BufferedInputStream bufin = null;
BufferedOutputStream bufout = null;
try {
    FileInputStream fis = new FileInputStream(in);
    bufin = new BufferedInputStream(fis);
    out.delete();
    FileOutputStream fos = new FileOutputStream(out);
    bufout = new BufferedOutputStream(fos);
...
voidcopyFile(File inFile, File outFile)
Copy a file from one file to another
BufferedInputStream is = null;
BufferedOutputStream os = null;
try {
    is = new BufferedInputStream(new FileInputStream(inFile));
    os = new BufferedOutputStream(new FileOutputStream(outFile));
    copyStream(is, os);
} finally {
    safeCloseStream(is);
...