Java Utililty Methods FileInputStream Copy

List of utility methods to do FileInputStream Copy

Description

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

Method

booleancopyFile(String srcPath, String dstPath, boolean replace)
copy a file
InputStream inputStream = null;
FileOutputStream fileOutputStream = null;
try {
    int byteRead;
    File srcFile = new File(srcPath);
    File dstFile = new File(dstPath);
    if (dstFile.exists() && !replace) {
        return false;
...
voidcopyFile(String srFile, String dtFile)
copy File
try {
    File f1 = new File(srFile);
    File f2 = new File(dtFile);
    InputStream in = new FileInputStream(f1);
    OutputStream out = new FileOutputStream(f2);
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
...
voidcopyFile(String srFile, String dtFile)
copy File
try {
    File f1 = new File(srFile);
    File f2 = new File(dtFile);
    copyFile(f1, f2);
} catch (FileNotFoundException ex) {
    System.out.println(ex.getMessage() + " in the specified directory.");
    System.exit(0);
} catch (IOException e) {
...
booleancopyFile(String srFile, String dtFile)
copy File
boolean ok = false;
try {
    File f1 = new File(srFile);
    File f2 = new File(dtFile);
    InputStream in = new FileInputStream(f1);
    OutputStream out = new FileOutputStream(f2);
    byte[] buf = new byte[1024];
    int len;
...
voidcopyFile(String srFilePath, String dtFilePath)
copy File
try {
    File srFile = new File(srFilePath);
    File dtFile = new File(dtFilePath);
    InputStream in = new FileInputStream(srFile);
    OutputStream out = new FileOutputStream(dtFile);
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
...
voidcopyFile(String target, String source)
copy File
byte[] bytes = getFileInBytes(source);
try {
    writeBytes(bytes, target);
} catch (IOException e) {
    e.printStackTrace();
voidcopyFileAndReName(String destPath, String srcPath, String srcFile, String destFile)
copy File And Re Name
(new File(destPath)).mkdirs();
File file = new File(srcPath + srcFile);
if (file.exists()) {
    FileInputStream input = new FileInputStream(file);
    FileOutputStream output = new FileOutputStream(destPath + "/" + destFile);
    byte[] b = new byte[1024 * 5];
    int len;
    while ((len = input.read(b)) != -1) {
...
voidcopyFileAsStream(String srcFilePathName, String dstFilePathName)
copy File As Stream
FileInputStream fis = new FileInputStream(srcFilePathName);
FileOutputStream fos = new FileOutputStream(dstFilePathName);
byte[] buf = new byte[1024];
int i = 0;
while ((i = fis.read(buf)) != -1) {
    fos.write(buf, 0, i);
fis.close();
...
booleancopyFileBin(File sourceFile, File targetFile)
copy File Bin
boolean deltas = (targetFile.lastModified() != sourceFile.lastModified());
if (!deltas) {
    deltas = deltas || (targetFile.length() != sourceFile.length());
if (deltas) {
    if (!targetFile.exists()) {
        File parentDir = targetFile.getParentFile();
        if (!parentDir.isDirectory()) {
...
voidcopyFileBinary(String source, String destination)
copy File Binary
FileInputStream readSource = new FileInputStream(source);
FileOutputStream outputDestination = new FileOutputStream(destination);
byte read[] = new byte[1024];
int count = 0;
while ((count = readSource.read(read, 0, 1024)) != -1) {
    outputDestination.write(read, 0, count);
outputDestination.flush();
...