Java Utililty Methods FileInputStream Copy

List of utility methods to do FileInputStream Copy

  1. HOME
  2. Java
  3. F
  4. FileInputStream Copy

Description

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

Method

File copyFile(File aSource, File aDest)
Copies a file from one location to another.
FileInputStream fis = new FileInputStream(aSource);
File out = aDest.isDirectory() ? new File(aDest, aSource.getName()) : aDest;
FileOutputStream fos = new FileOutputStream(out);
byte[] buf = new byte[8192];
for (int i = fis.read(buf); i != -1; i = fis.read(buf))
 fos.write(buf, 0, i);
fis.close();
fos.close();
...
void copyFile(File base, String relfilepath, File targetdir)
copy File
File sourcefile = new File(base, relfilepath);
File targetfile = new File(targetdir, relfilepath);
if (!targetfile.exists()) {
 File parentfile = sourcefile.getParentFile();
 String relpfilepath = getRelativePath(base, parentfile);
 File targetfiledir = new File(targetdir, relpfilepath);
 if (!targetfiledir.exists())
 targetfiledir.mkdirs();
...
void copyFile(File copyFrom, File copyTo)
copy File
FileInputStream inputStream = new FileInputStream(copyFrom);
FileOutputStream outputStream = new FileOutputStream(copyTo);
copy(inputStream, outputStream);
inputStream.close();
outputStream.close();
void copyFile(File copyFrom, File copyTo)
Copy a file to a file location
InputStream from = new FileInputStream(copyFrom);
OutputStream to = new FileOutputStream(copyTo);
copyStream(from, to);
void copyFile(File destfile, File srcfile)
Copy source file to destination file.
byte[] bytearr = new byte[512];
int len = 0;
FileInputStream input = new FileInputStream(srcfile);
File destDir = destfile.getParentFile();
destDir.mkdirs();
FileOutputStream output = new FileOutputStream(destfile);
try {
 while ((len = input.read(bytearr)) != -1) {
...
void copyFile(File destFile, File srcFile)
copy File
if (!srcFile.exists() || null == destFile) {
 return;
if (null != destFile.getParentFile()) {
 destFile.getParentFile().mkdirs();
FileInputStream fis = null;
FileOutputStream fos = null;
...
void copyFile(File destination, File source)
Copies the contents of one file to another.
copyFile(destination, source, false);
void copyFile(File existingFile, File destFile)
copy File
FileInputStream source = null;
FileOutputStream destination = null;
byte[] buffer;
int bytes_read;
try {
 source = new FileInputStream(existingFile);
 destination = new FileOutputStream(destFile);
 buffer = new byte[1024];
...
void copyFile(File file, File destPath)
Copy a file to destPath.
if (file.isDirectory()) {
 return;
if (!destPath.exists()) {
 destPath.mkdirs();
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(new File(destPath, file.getName()));
...
void copyFile(File file, File dir)
Copy file file to location dir.
if (!file.exists() || !file.canRead()) {
 throw new IOException("File does not exist or is not readable: " + file.getAbsolutePath());
if (!dir.exists() || !dir.isDirectory()) {
 throw new IOException("Destination does not exist or is not a directory: " + dir.getAbsolutePath());
File outFile = new File(dir, file.getName());
if (outFile.exists() && !outFile.canWrite()) {
...


AltStyle によって変換されたページ (->オリジナル) /