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

voidcopyFile(File src, File dst)
Copies the src to dst.
if (!src.isFile() || dst.isDirectory()) {
    return;
dst.getParentFile().mkdirs();
if (dst.exists()) {
    dst.delete();
try {
...
booleancopyFile(File src, File dst)
copy File
if (!src.exists()) {
    return false;
if (!dst.getParentFile().exists()) {
    dst.getParentFile().mkdirs();
} else {
    if (dst.exists()) {
        dst.delete();
...
voidcopyFile(File src, File target)
copy File
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
    in = new BufferedInputStream(new FileInputStream(src));
    out = new BufferedOutputStream(new FileOutputStream(target));
    pump(in, out);
} finally {
    if (in != null)
...
voidcopyFile(File src, File targetDir, boolean onlyNew)
copy File
File destFile = new File(targetDir, src.getName());
copy(src, destFile, onlyNew);
voidcopyFile(File src, String target)
copy a file object;
int read = 0;
byte[] bytes = new byte[4096];
BufferedInputStream in = new BufferedInputStream(new FileInputStream(src));
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(target)));
while ((read = in.read(bytes)) >= 0) {
    out.write(bytes, 0, read);
in.close();
...
voidcopyFile(File srcFile, File destFile, boolean createCopy)
Copy a File.
if (createCopy) {
    if (srcFile.equals(destFile) || destFile.exists()) {
        int i = 1;
        String name = getFileNameWithoutExtension(srcFile);
        String ext = getFileExtension(srcFile);
        do {
            destFile = new File(destFile.getParentFile(), name + "(" + i++ + ")" + ext); 
        } while (destFile.exists());
...
voidcopyFile(File srcFile, File detFolder)
copy File
BufferedInputStream bin = null;
BufferedOutputStream bout = null;
try {
    String fileName = srcFile.getName();
    String targetFileName = detFolder.getAbsolutePath() + File.separatorChar + fileName;
    bin = new BufferedInputStream(new FileInputStream(srcFile));
    bout = new BufferedOutputStream(new FileOutputStream(new File(targetFileName)));
    byte[] buffer = new byte[1024];
...
FilecopyFile(File srcFile, File targetFolder)
copy File
BufferedInputStream bufIn = new BufferedInputStream(new FileInputStream(srcFile));
String targetFilePath = targetFolder.getAbsolutePath() + File.separator + srcFile.getName();
BufferedOutputStream bufOut = new BufferedOutputStream(new FileOutputStream(targetFilePath));
byte[] buf = new byte[1024];
int cnt = 0;
while ((cnt = bufIn.read(buf)) != -1) {
    bufOut.write(buf, 0, cnt);
bufOut.close();
bufIn.close();
return new File(targetFilePath);
voidcopyFile(final File from, final File to)
copy File
final InputStream inputStream = new BufferedInputStream(new FileInputStream(from));
copyFile(inputStream, to);
voidcopyFile(final File fSource, final File fDest)
Copy the file fSource to the file fDest.
if (fSource == null || fDest == null)
    throw new NullPointerException();
File fDestDir = fDest.getParentFile();
if (fDestDir != null) {
    if (fDestDir.exists()) {
        if (fDestDir.isFile())
            throw new FileNotFoundException(
                    "The destination directory " + fDestDir + " is not a directory !");
...