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 source, File destination)
This method copies a single file.
copyFile(new FileInputStream(source), destination);
voidcopyFile(File source, File destination)
Copies a file from the given streams.
copyFile(new FileInputStream(source), new FileOutputStream(destination));
voidcopyFile(File source, File destination)
copy File
if (destination.isDirectory())
    destination = new File(destination, source.getName());
FileInputStream input = new FileInputStream(source);
copyFile(input, destination);
booleancopyFile(File source, File target)
Creates a copy of a file
boolean backup = true;
try {
    byte[] buf = new byte[COPY_BUFFER_SIZE];
    FileInputStream fis = new FileInputStream(source);
    OutputStream fos = createOutputStream(target);
    int len;
    do {
        len = fis.read(buf);
...
voidcopyFile(File source, File target)
Copies a file to a different location
InputStream inputStream = new FileInputStream(source);
OutputStream outputStream = new FileOutputStream(target);
try {
    copyFile(inputStream, outputStream);
} finally {
    if (inputStream != null) {
        inputStream.close();
    if (outputStream != null) {
        outputStream.close();
voidcopyFile(File source, File target)
copy File
InputStream in = null;
OutputStream out = null;
try {
    in = new FileInputStream(source);
    out = new FileOutputStream(target);
    while (true) {
        int data = in.read();
        if (data == -1) {
...
voidcopyFile(File source, File target)
copy File
int size = (int) source.length();
byte[] buffer = new byte[size];
InputStream in = null;
try {
    in = new FileInputStream(source);
    in.read(buffer);
} catch (IOException ex) {
    throw new RuntimeException(ex);
...
voidcopyFile(File source, File target)
copy File
try (InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(target)) {
    byte[] buf = new byte[1024];
    int length;
    while ((length = in.read(buf)) > 0) {
        out.write(buf, 0, length);
voidcopyFile(File source, File target)
copy File
if (!target.exists() || source.length() != target.length()
        || source.lastModified() > target.lastModified()) {
    copyFile(new FileInputStream(source), target);
voidcopyFile(File source, File target)
copy File
try (FileInputStream in = new FileInputStream(source);
        FileOutputStream out = new FileOutputStream(target)) {
    copyStream(in, out);