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 input, File output)
Helper function to copy the file.
FileInputStream inputStream = new FileInputStream(input);
FileOutputStream outputStream = new FileOutputStream(output);
int lengthStream;
byte[] buff = new byte[1024];
while ((lengthStream = inputStream.read(buff)) > 0) {
    outputStream.write(buff, 0, lengthStream);
outputStream.close();
...
voidcopyFile(File inputFile, File outputFile)
Copy a file from one location to another, using buffered writing
OutputStream out = null;
InputStream in = null;
try {
    in = new FileInputStream(inputFile);
    out = new FileOutputStream(outputFile);
    byte[] buffer = new byte[64000];
    int bytes_read;
    while ((bytes_read = in.read(buffer)) != -1) {
...
voidcopyFile(File inputFile, File outputFile)
Copies the content from inputFile into outputFile.
InputStream is = null;
OutputStream os = null;
try {
    is = new FileInputStream(inputFile);
    if (!outputFile.exists() && !outputFile.createNewFile())
        throw new IOException("Failed to create " + outputFile.getAbsolutePath() + ".");
    os = new FileOutputStream(outputFile);
    byte[] buf = new byte[1024];
...
voidcopyFile(File inputFile, File outputFile)
Copies the contents of any disk file to a specified output file.
File parent;
FileInputStream in = null;
FileOutputStream out = null;
CRC32 crcSum;
int writeCrc;
if (inputFile == null | outputFile == null)
    throw new IllegalArgumentException("null pointer");
if (inputFile.equals(outputFile))
...
voidcopyFile(File inputFile, OutputStream os)
Utility method to copy a file into an java.io.OutputStream .
FileInputStream fis = null;
try {
    fis = new FileInputStream(inputFile);
    byte[] buffer = new byte[1024 * 1024];
    int n = 0;
    while ((n = fis.read(buffer)) != -1) {
        os.write(buffer, 0, n);
} finally {
    if (fis != null)
        fis.close();
booleancopyFile(File of, File nf)
copy File
InputStream in;
try {
    in = new FileInputStream(of);
    OutputStream out = new FileOutputStream(nf);
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
...
voidcopyFile(File oldFile, File newFile)
Copy file contents.
FileOutputStream out = null;
FileInputStream in = null;
try {
    out = new FileOutputStream(newFile);
    in = new FileInputStream(oldFile);
    byte[] buf = new byte[4096];
    long size = oldFile.length();
    long copied = 0;
...
booleancopyFile(File oldFile, String newPath)
copy File
if (!oldFile.exists() || !oldFile.isFile()) {
    return false;
InputStream in = null;
FileOutputStream fos = null;
try {
    int len;
    in = new FileInputStream(oldFile);
...
voidcopyFile(File orig, File dest)
copy File
FileInputStream fis = new FileInputStream(orig);
FileOutputStream fos = new FileOutputStream(dest);
copyData(fis, fos);
booleancopyFile(File orig, File dest, boolean overwrite)
copy File
if (!orig.exists() && !orig.canRead())
    return false;
if (dest.exists() && !overwrite)
    return false;
try {
    InputStream in = new FileInputStream(orig);
    FileOutputStream out = new FileOutputStream(dest);
    return copyStream(in, out);
...