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(String sourceFilePath, String destinationFilePath)
copy File
InputStream inStream = null;
OutputStream outStream = null;
File sourceFile = new File(sourceFilePath);
File destinationFile = new File(destinationFilePath);
inStream = new FileInputStream(sourceFile);
outStream = new FileOutputStream(destinationFile); 
byte[] buffer = new byte[1024];
int length;
...
booleancopyFile(String sourcePath, String newPath)
Copy an existing file to a new location.
InputStream inStream = null;
OutputStream outStream = null;
try {
    File afile = new File(sourcePath);
    File bfile = new File(newPath);
    inStream = new FileInputStream(afile);
    outStream = new FileOutputStream(bfile);
    byte[] buffer = new byte[1024];
...
StringcopyFile(String src, File dest)
copy File
return copyFile(new File(src), dest);
voidcopyFile(String src, String dest)
modelled on example from http://javaalmanac.com/, which says "All the code examples from the book are made available here for you to copy and paste into your programs."
if (!new File(src).exists()) {
    return;
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
...
voidcopyFile(String src, String dest)
copy File
int len;
FileInputStream in = new FileInputStream(new File(src));
FileOutputStream out = new FileOutputStream(new File(dest));
byte[] buf = new byte[1024];
while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
in.close();
...
voidcopyFile(String src, String dest)
Copies a file.
FileInputStream in = new FileInputStream(new File(src));
FileOutputStream out = new FileOutputStream(new File(dest));
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0)
    out.write(buf, 0, len);
in.close();
out.close();
...
voidcopyFile(String src, String dest)
copy File
InputStream is = null;
FileOutputStream fos = null;
try {
    is = new FileInputStream(src);
    fos = new FileOutputStream(dest);
    int c = 0;
    byte[] array = new byte[1024];
    while ((c = is.read(array)) >= 0) {
...
voidcopyFile(String src, String dest)
Copies the specified source file to the specified destination file.
copyFile(new File(src), new File(dest));
voidcopyFile(String src, String dst)
copy File
FileOutputStream fos = null;
FileInputStream fis = null;
try {
    fos = new FileOutputStream(dst);
    fis = new FileInputStream(src);
    byte[] buf = new byte[4096];
    int nread = fis.read(buf);
    while (nread > 0) {
...
FilecopyFile(String src, String dst)
copy File
File srcFile = new File(src);
File dstFile = new File(dst);
if (dstFile.isDirectory()) {
    dstFile = new File(dst + "/" + srcFile.getName());
dstFile.createNewFile();
InputStream in = new FileInputStream(srcFile);
OutputStream out = new FileOutputStream(dstFile);
...