Java BufferedReader Copy copyFile(File source, File dest)

Here you can find the source of copyFile(File source, File dest)

Description

change the dest's opengraph id from OG to file path

License

LGPL

Parameter

Parameter Description
source a parameter
dest a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static void copyFile(File source, File dest) throws IOException 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.*;

public class Main {
    /**/*w  ww .  jav  a2  s. co  m*/
     * change the dest's opengraph id from OG to file path
     * @param source
     * @param dest
     * @throws IOException
     */
    public static void copyFile(File source, File dest) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(source));
        BufferedWriter bw = new BufferedWriter(new FileWriter(dest));
        String result = "";
        try {
            while ((result = br.readLine()) != null) {
                String a = dest.getName().replaceAll("\\.", "_");
                result = result.replaceAll("OG_", a);
                bw.write(result + "\r\n");
                bw.flush();
            }
        } finally {
            br.close();
            bw.close();
        }
    }
}

Related

  1. copyFile(BufferedReader in, BufferedWriter out)
  2. copyFile(File from, File to)
  3. copyFile(File orgFile, File dstFile)
  4. copyFile(File original, File copy)
  5. copyFile(File src, File dst)
  6. copyFile(String orig, String dest)
  7. copyFile(String source, String dest)
  8. copyFile(String src, String dst)