Java FileInputStream Copy copyFile(String oldPathFile, String newPathFile)

Here you can find the source of copyFile(String oldPathFile, String newPathFile)

Description

copy File

License

Open Source License

Declaration

@SuppressWarnings({ "unused", "resource" })
public static void copyFile(String oldPathFile, String newPathFile) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.InputStream;

public class Main {

    @SuppressWarnings({ "unused", "resource" })
    public static void copyFile(String oldPathFile, String newPathFile) {
        try {/*from   w  w w.  ja  va2  s  . c o  m*/
            int bytesum = 0;
            int byteread = 0;
            File oldfile = new File(oldPathFile);
            if (oldfile.exists()) {
                InputStream inStream = new FileInputStream(oldPathFile);
                FileOutputStream fs = new FileOutputStream(newPathFile);
                byte[] buffer = new byte[1444];
                while ((byteread = inStream.read(buffer)) != -1) {
                    bytesum += byteread;
                    fs.write(buffer, 0, byteread);
                }
                inStream.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. copyFile(String input, String output)
  2. copyFile(String inputFile, String outputFile)
  3. copyFile(String oldFile, String newFile)
  4. copyFile(String oldPath, String newPath)
  5. copyFile(String oldPath, String newPath)
  6. copyFile(String original, String copy)
  7. copyFile(String pathOld, String pathNew)
  8. copyFile(String pathOrig, String pathDst)
  9. copyFile(String quelle, String ziel)