List of utility methods to do FileInputStream Copy
void | copyFile(File targetFile, File file) Copy file to file InputStream is = new FileInputStream(file); FileOutputStream fos = new FileOutputStream(targetFile); byte[] buffer = new byte[1024]; int i = 0; while ((i = is.read(buffer)) != -1) { fos.write(buffer, 0, i); is.close(); ... |
void | copyFile(File targetFile, File file) copy File if (targetFile.exists()) { return; } else { createFile(targetFile, true); try { FileInputStream is = new FileInputStream(file); FileOutputStream fos = new FileOutputStream(targetFile); ... |
void | copyFile(final File from, final File to) Copies a file to a different location. if (from.getCanonicalFile().equals(to.getCanonicalFile())) { return; createNecessaryDirectories(to); FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream(from); ... |
void | copyFile(final File fromFile, final File toFile) copy File InputStream in = new FileInputStream(fromFile); OutputStream out = new FileOutputStream(toFile); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); in.close(); ... |
void | copyFile(final File fromFile, final File toFile) Copy file to file. FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream(fromFile); out = new FileOutputStream(toFile); streamToStream(in, out); } finally { if (out != null) { ... |
void | copyFile(final File in, final File out) Copy a file FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out); byte[] buf = new byte[BUFSIZE]; int i = 0; try { while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); fis.close(); fos.close(); } catch (IOException e) { e.printStackTrace(); |
boolean | copyFile(final File oldfile, final File newfile) copy File FileInputStream fis; FileOutputStream fos; int len; byte[] buf; try { if (!newfile.exists()) { newfile.createNewFile(); if (!oldfile.canRead() || !newfile.canWrite()) { return false; fis = new FileInputStream(oldfile); fos = new FileOutputStream(newfile); buf = new byte[4096]; while ((len = fis.read(buf)) > 0) { fos.write(buf, 0, len); fis.close(); fos.close(); } catch (final IOException e) { e.printStackTrace(); return true; |
void | copyFile(final File source, final File dest) copy File if (!dest.getParentFile().exists()) { String dir = dest.getParentFile().toString(); new File(dir).mkdir(); InputStream in = null; OutputStream out = null; if (source.exists()) { try { ... |
void | copyFile(final File source, final File target) Copy a file if (!source.exists() || !source.canRead()) { throw new IllegalArgumentException("Can't read from given source file: " + source.getAbsolutePath()); if (!target.exists()) { try { if (!target.createNewFile()) { throw new IllegalArgumentException( "Can't write to given target file: " + target.getAbsolutePath()); ... |
void | copyFile(final File src, final File dest) Copies a file or directory from one location to another location on a local system. Note: The destination location must exist, otherwise a IOException will be thrown. if (src.isDirectory()) { if (!dest.exists()) { dest.mkdir(); final String files[] = src.list(); for (final String file : files) { final File srcFile = new File(src, file); final File destFile = new File(dest, file); ... |