Java Utililty Methods BufferedInputStream Copy

List of utility methods to do BufferedInputStream Copy

Description

The list of methods to do BufferedInputStream Copy are organized into topic(s).

Method

booleancopyFile(File inFile, File outFile)
Copies a file.
BufferedInputStream in = null;
BufferedOutputStream out = null;
boolean result = true;
try {
    in = new BufferedInputStream(new FileInputStream(inFile));
    out = new BufferedOutputStream(new FileOutputStream(outFile));
    byte[] buffer = new byte[4096];
    int n;
...
voidcopyFile(File inputFile, File outputFile)
Copie un fichier vers un autre
BufferedInputStream fr = new BufferedInputStream(new FileInputStream(inputFile));
BufferedOutputStream fw = new BufferedOutputStream(new FileOutputStream(outputFile));
byte[] buf = new byte[8192];
int n;
while ((n = fr.read(buf)) >= 0)
    fw.write(buf, 0, n);
fr.close();
fw.close();
...
voidcopyFile(File origem, File destino)
copy File
copyFile(origem, destino, false);
voidcopyFile(File source, File dest)
Copies the file source to dest.
The destination file WILL be overwritten if it's already existed.
if (!dest.exists())
    dest.createNewFile();
byte[] buffer = new byte[1024];
int bytesRead = 0;
try (BufferedInputStream bin = new BufferedInputStream(new FileInputStream(source));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest));) {
    while ((bytesRead = bin.read(buffer)) != -1) {
        bos.write(buffer, 0, bytesRead);
...
booleancopyFile(File source, File dest, boolean deleteIfExists)
Copies a file.
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
    if (dest.exists()) {
        if (!deleteIfExists)
            return false;
    in = new BufferedInputStream(new FileInputStream(source));
...
booleancopyFile(File source, File dest, boolean deleteIfExists)
Copies a file.
if (dest.exists() && !deleteIfExists) {
    return false;
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(source));
        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dest))) {
    int el;
    while ((el = in.read()) >= 0) {
        out.write(el);
...
voidcopyFile(File source, File destination)
Copy a single file or directory from one location to another.
InputStream istream = new FileInputStream(source);
OutputStream ostream = new FileOutputStream(destination);
BufferedInputStream oBuffInputStream = new BufferedInputStream(istream);
int length;
byte[] bytes = new byte[1024];
while ((length = oBuffInputStream.read(bytes)) > 0) {
    ostream.write(bytes, 0, length);
istream.close();
ostream.close();
voidcopyFile(File source, File destination)
copy File
byte[] buffer = new byte[100000];
BufferedInputStream bufferedInputStream = null;
BufferedOutputStream bufferedOutputStream = null;
try {
    bufferedInputStream = new BufferedInputStream(new FileInputStream(source));
    bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(destination));
    int size;
    while ((size = bufferedInputStream.read(buffer)) > -1) {
...
voidcopyFile(File source, File destination, boolean overwrite)
copy File
Assert.isLegal(source != null);
Assert.isLegal(source.isFile());
Assert.isLegal(destination != null);
destination = getDestinationFile(source, destination);
if (exists(destination) && !overwrite) {
    return;
if (isDirectory(destination)) {
...
voidcopyFile(File source, File target)
copy File
InputStream in = null;
OutputStream out = null;
try {
    in = new BufferedInputStream(new FileInputStream(source));
    out = new BufferedOutputStream(new FileOutputStream(target));
    int ch;
    while ((ch = in.read()) != -1) {
        out.write(ch);
...