How to copy file using FileReader in java

public static void copyFile(String sourcePath, String destinationPath){
           
        
             File inputFile = new File(sourcePath);
             File outputFile = new File(destinationPath);

              try {
                FileReader in = new FileReader(inputFile);
                FileWriter out = new FileWriter(outputFile);
                  int c;

                  while ((c = in.read()) != -1)
                  out.write(c);
                  
                  in.close();
                  out.close();
            } catch (FileNotFoundException e) {
               
                e.printStackTrace();
            } catch (IOException e) {
               
                e.printStackTrace();
            }
           
           
           
           
        }

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Use of req.query, req.params and req.body in NODE JS

How to capture finger prints in java