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

booleancopyFile(File src, File toDir)
copy File
if (src.isFile()) {
    File tgt = new File(toDir, src.getName());
    if (tgt.createNewFile()) {
        byte[] data = getContents(src);
        setContents(tgt, data);
        return true;
return false;
voidcopyFile(File srcFile, File destFile)
Copy a file to another
FileOutputStream os = null;
try (FileInputStream is = new FileInputStream(srcFile)) {
    os = new FileOutputStream(destFile);
    byte[] buffer = new byte[1024];
    int bcount;
    while ((bcount = is.read(buffer)) > 0)
        os.write(buffer, 0, bcount);
} finally {
...
voidcopyFile(File srcFile, File destFile)
copy File
FileOutputStream fos = null;
FileInputStream fis = null;
try {
    byte[] tempBuff = new byte[10240];
    fis = new FileInputStream(srcFile);
    fos = new FileOutputStream(destFile);
    int readCnt;
    while (true) {
...
voidcopyFile(File srcFile, File destFile)
copy File
InputStream in = new FileInputStream(srcFile);
copyFile(in, destFile);
in.close();
voidcopyFile(File srcFile, File destFile)
copy File
copyFile(srcFile, destFile, true);
voidcopyFile(File srcFile, File destFile)
copy File
FileOutputStream fos = new FileOutputStream(destFile);
try {
    copyToOutputStream(srcFile, fos);
} finally {
    fos.close();
voidCopyFile(File srcFile, File destFile)
Copy File
try {
    int bytesum = 0;
    int byteread = 0;
    InputStream inStream = new FileInputStream(srcFile);
    FileOutputStream fs = new FileOutputStream(destFile);
    byte[] buffer = new byte[1444];
    while ((byteread = inStream.read(buffer)) != -1) {
        bytesum += byteread;
...
booleancopyFile(File srcFile, File destFile)
copy File
boolean result = false;
try {
    InputStream in = new FileInputStream(srcFile);
    try {
        result = copyToFile(in, destFile);
    } finally {
        in.close();
} catch (IOException e) {
    result = false;
return result;
voidcopyFile(File srcFile, File destFile)
copy File
if (!srcFile.getPath().toLowerCase().endsWith(JPG) && !srcFile.getPath().toLowerCase().endsWith(JPEG)) {
    return;
final InputStream in = new FileInputStream(srcFile);
final OutputStream out = new FileOutputStream(destFile);
try {
    long millis = System.currentTimeMillis();
    CRC32 checksum;
...
voidcopyFile(File srcFile, File destFile)
Copies a source file to a target file.
if (!(srcFile.exists() && srcFile.isFile()))
    throw new IllegalArgumentException("Source file doesn't exist: " + srcFile.getAbsolutePath());
if (destFile.exists() && destFile.isDirectory())
    throw new IllegalArgumentException("Destination file is directory: " + destFile.getAbsolutePath());
FileInputStream in = new FileInputStream(srcFile);
FileOutputStream out = new FileOutputStream(destFile);
byte[] buffer = new byte[4096];
int no = 0;
...