Java Utililty Methods FileInputStream Copy

List of utility methods to do FileInputStream Copy

Description

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

Method

voidcopyFile(File src, File dest)
This method copies the content of a file (possibly directory) in another file.
InputStream in = null;
OutputStream out = null;
if (dest.isDirectory())
    dest = new File(dest, src.getName());
try {
    in = new FileInputStream(src);
    out = new FileOutputStream(dest);
    byte[] buf = new byte[1024];
...
voidcopyFile(File src, File dest)
copy File
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest);
try {
    writeInputToOutput(in, out, 8192);
} finally {
    in.close();
    out.close();
voidcopyFile(File src, File dest)
copy File
copyFile(src, dest, null);
voidcopyFile(File src, File dest)
copy File
FileInputStream fIn = null;
FileOutputStream fOut = null;
try {
    fIn = new FileInputStream(src);
    fOut = new FileOutputStream(dest);
    copy(fIn, fOut);
} finally {
    if (fIn != null)
...
voidcopyFile(File src, File dest, int bufSize)
This method copies a file.
byte[] buffer = new byte[bufSize];
InputStream in = null;
OutputStream out = null;
try {
    in = new FileInputStream(src);
    out = new FileOutputStream(dest);
    while (true) {
        int read = in.read(buffer);
...
voidcopyFile(File src, File dst)
Copies src file to dst file.
OutputStream out = null;
InputStream in = new FileInputStream(src);
try {
    String dstAbsPath = dst.getAbsolutePath();
    String dstDir = dstAbsPath.substring(0, dstAbsPath.lastIndexOf(File.separator));
    File dir = new File(dstDir);
    if (!dir.exists() && !dir.mkdirs()) {
        throw new IOException("Fail to create the directory: " + dir.getAbsolutePath());
...
booleancopyFile(File src, File dst)
copy File
try {
    InputStream in = new FileInputStream(src);
    OutputStream out = new FileOutputStream(dst);
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    in.close();
    out.close();
    return true;
} catch (Exception e) {
    return false;
voidcopyFile(File src, File dst)
copy File
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
in.close();
...
voidcopyFile(File src, File dst)
Copy a file.
copyOrAppend(src, dst, false);
voidcopyFile(File src, File dst)
copy File
try {
    FileInputStream in = null;
    FileOutputStream out = null;
    try {
        out = new FileOutputStream(dst);
        in = new FileInputStream(src);
        byte[] buffer = new byte[1024];
        int len = 0;
...