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(InputStream in, String destFile)
Copy a file to another file using a static buffer of DEFAULT_BUFFER_SIZE
copyFile(in, destFile, DEFAULT_BUFFER_SIZE);
voidcopyFile(OutputStream out, InputStream in)
copy File
byte buffer[] = new byte[4096];
while (true) {
    int r = in.read(buffer);
    if (r <= 0)
        break;
    out.write(buffer, 0, r);
voidcopyFile(String f1, String f2)
copy f1 to f2
FileInputStream is = new FileInputStream(f1);
FileOutputStream f = new FileOutputStream(f2);
byte[] b = new byte[1024];
int m = is.read(b);
while (m != -1) {
    f.write(b, 0, m);
    m = is.read(b);
f.close();
voidcopyFile(String fileIn, String fileOut)
copy File
copyFile(new File(fileIn), new File(fileOut));
booleancopyFile(String fileInName, String fileOutName)
copy File
try {
    FileInputStream in = new FileInputStream(fileInName);
    FileOutputStream out = new FileOutputStream(fileOutName);
    byte buffer[] = new byte[16];
    int n;
    while ((n = in.read(buffer)) > -1)
        out.write(buffer, 0, n);
    out.close();
...
voidcopyFile(String fileName, String fromDir, String toDir)
Utility method to copy a file from one directory to another
copyFile(new File(fromDir + File.separator + fileName), new File(toDir + File.separator + fileName));
voidcopyFile(String fileOutPut, String fileIn)
copy File
FileInputStream fileInputStream = new FileInputStream(fileIn);
FileOutputStream fileOutputStream = new FileOutputStream(fileOutPut);
byte[] by = new byte[1024];
int len;
while ((len = fileInputStream.read(by)) != -1) {
    fileOutputStream.write(by, 0, len);
fileInputStream.close();
...
booleancopyFile(String from, String to)
copy File
File fromFile, toFile;
fromFile = new File(from);
toFile = new File(to);
FileInputStream fis = null;
FileOutputStream fos = null;
try {
    toFile.createNewFile();
    fis = new FileInputStream(fromFile);
...
voidcopyFile(String fromFile, String toFile)
Copies contents from one file to another
File from = new File(fromFile);
File to = new File(toFile);
FileInputStream inStream = new FileInputStream(from);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(to));
copyInputStream(inStream, out);
voidcopyFile(String fromFilePath, String toFilePath)
copy File
int bytesum = 0;
int byteread = 0;
File oldfile = new File(fromFilePath);
if (oldfile.exists()) {
    InputStream inStream = new FileInputStream(fromFilePath);
    FileOutputStream fs = new FileOutputStream(toFilePath);
    byte[] buffer = new byte[1444];
    while ((byteread = inStream.read(buffer)) != -1) {
...