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 source, File target)
Copies a file from source to target.
if (source.isDirectory()) {
    File subtarget = new File(target, source.getName());
    copyDirContent(source, subtarget);
} else {
    if (!target.exists()) {
        if (!target.createNewFile()) {
            throw new IOException("Unable to create target file");
    } else if (target.isDirectory()) {
        target = new File(target, source.getName());
    byte[] buf = new byte[2048];
    InputStream in = new BufferedInputStream(new FileInputStream(source));
    OutputStream out = new BufferedOutputStream(new FileOutputStream(target));
    int len;
    while ((len = in.read(buf)) != -1) {
        out.write(buf, 0, len);
    out.flush();
    in.close();
    out.close();
voidcopyFile(File source, File target)
Binary copy of a file from source to target.
FileOutputStream fos = null;
FileInputStream fis = null;
BufferedInputStream bis;
int n;
byte[] buf = new byte[2048];
try {
    fos = new FileOutputStream(target);
    fis = new FileInputStream(source);
...
voidcopyFile(File sourceFile, File targetFile)
copy File
InputStream from = new BufferedInputStream(new FileInputStream(sourceFile));
OutputStream to = new BufferedOutputStream(new FileOutputStream(targetFile));
byte[] buffer = new byte[16 * 1024];
int bytesRead;
while ((bytesRead = from.read(buffer)) != -1) {
    to.write(buffer, 0, bytesRead);
to.flush();
...
voidcopyFile(File sourceFile, File targetFile)
Copies the specified sourceFile to the specified targetFile.
if (sourceFile == null || targetFile == null) {
    throw new NullPointerException("sourceFile and targetFile must not be null"); 
File directory = targetFile.getParentFile();
if (!directory.exists() && !directory.mkdirs()) {
    throw new IOException("Could not create directory '" + directory + "'"); 
InputStream inputStream = null;
...
voidcopyFile(File sourceFile, File targetFile)
copy File
BufferedInputStream inBuff = null;
BufferedOutputStream outBuff = null;
try {
    inBuff = new BufferedInputStream(new FileInputStream(sourceFile));
    outBuff = new BufferedOutputStream(new FileOutputStream(targetFile));
    byte[] buffer = new byte[BUFFER];
    int length;
    while ((length = inBuff.read(buffer)) != -1) {
...
voidcopyFile(File src, File dest)
Insert the method's description here.
InputStream ss = null;
OutputStream ds = null;
try {
    ss = new BufferedInputStream(new FileInputStream(src));
    ds = new BufferedOutputStream(new FileOutputStream(dest));
    copyStream(ss, ds);
} finally {
    if (ds != null) {
...
voidcopyFile(File src, File dest)
copy File
FileInputStream in = new FileInputStream(src);
try {
    byte[] bs = getContentBytes(in);
    saveFile(dest, bs);
} finally {
    in.close();
booleancopyFile(File src, File dest)
copy File
InputStream in = null;
OutputStream out = null;
byte[] buf = null;
int bufLen = 20000 * 1024;
try {
    in = new BufferedInputStream(new FileInputStream(src));
    out = new BufferedOutputStream(new FileOutputStream(dest));
    buf = new byte[bufLen];
...
voidcopyFile(File src, File dest)
Copies a file or directory
if (!src.exists())
    throw new IOException("File not found '" + src.getAbsolutePath() + "'");
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
BufferedInputStream in = new BufferedInputStream(new FileInputStream(src));
byte[] read = new byte[4096];
int len;
while ((len = in.read(read)) > 0)
    out.write(read, 0, len);
...
intcopyFile(File src, File dst)
Copy one file to another.
int totalCopied = 0;
if (dst.isDirectory())
    dst = new File(dst, src.getName());
InputStream from = null;
OutputStream to = null;
try {
    from = new FileInputStream(src);
    to = new FileOutputStream(dst);
...