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 srcFile, File destFile)
copy File
if (srcFile.equals(destFile)) {
    return;
copyStream(new FileInputStream(srcFile), new FileOutputStream(destFile));
voidcopyFile(File srcFile, File destFile)
Copy a file preserving the date.
if (destFile.exists() && destFile.isDirectory()) {
    throw new IOException("Destination '" + destFile + "' exists but is a directory");
FileInputStream input = new FileInputStream(srcFile);
try {
    FileOutputStream output = new FileOutputStream(destFile);
    try {
        copy(input, output);
...
voidcopyFile(File srcFile, File destFile, boolean recursive)
copy File
if (recursive) {
    if (!destFile.isDirectory()) {
        throw new IOException("Destination must be a directory.");
    copyFileR(srcFile, destFile);
} else {
    copyFile(srcFile, destFile);
voidcopyFile(File srcFile, File dstFile)
copy File
FileInputStream src = new FileInputStream(srcFile);
try {
    copyFile(src, dstFile);
} finally {
    src.close();
voidcopyFile(File srcFile, File dstFile)
copy File
byte[] buf = new byte[1024];
OutputStream ostream = new FileOutputStream(dstFile);
InputStream istream = new FileInputStream(srcFile);
try {
    int numBytes = 0;
    while ((numBytes = istream.read(buf)) >= 0) {
        ostream.write(buf, 0, numBytes);
} finally {
    ostream.close();
voidcopyFile(File srcFile, File dstFile)
Copia de ficheros
InputStream in = null;
OutputStream out = null;
try {
    in = new FileInputStream(srcFile);
    out = new FileOutputStream(dstFile);
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
...
voidcopyFile(File srcFile, File dstFile)
copy File
dstFile.getParentFile().mkdirs();
FileInputStream input = null;
FileOutputStream output = null;
try {
    input = new FileInputStream(srcFile);
    output = new FileOutputStream(dstFile);
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];
...
voidcopyFile(File srcPath, File dstPath)
copy File
InputStream in = new FileInputStream(srcPath);
OutputStream out = new FileOutputStream(dstPath);
copy(in, out);
in.close();
out.close();
voidcopyfile(File srFile, File dtFile)
copyfile
InputStream in = new FileInputStream(srFile);
File desDir = dtFile.getParentFile();
if (!desDir.exists()) {
    boolean ret = desDir.mkdirs();
    if (!ret)
        throw new IOException("Cannot create directory " + desDir.getName());
OutputStream out = new FileOutputStream(dtFile);
...
voidcopyFile(File target, File source)
Copies a file.
FileInputStream in = null;
try {
    in = new FileInputStream(source);
    copyToFile(target, in);
    in.close();
} catch (IOException e) {
    if (null != in) {
        closeQuietly(in);
...