Here you can find the source of copyFile(String srcFileName, String destFileName)
Parameter | Description |
---|---|
srcFileName | Source file name |
destFileName | Destination file name |
Parameter | Description |
---|---|
IOException | IOException |
public static void copyFile(String srcFileName, String destFileName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class Main { /**//from w ww .j av a 2 s . com * Copy a file to another position * @param srcFileName Source file name * @param destFileName Destination file name * @throws IOException IOException */ public static void copyFile(String srcFileName, String destFileName) throws IOException { BufferedReader br = new BufferedReader(new FileReader(srcFileName)); BufferedWriter bw = new BufferedWriter(new FileWriter(destFileName)); String line; while ((line = br.readLine()) != null) { bw.write(line); bw.newLine(); } br.close(); bw.close(); } }