Example usage for java.io FileWriter FileWriter

List of usage examples for java.io FileWriter FileWriter

Introduction

In this page you can find the example usage for java.io FileWriter FileWriter.

Prototype

public FileWriter(FileDescriptor fd) 

Source Link

Document

Constructs a FileWriter given a file descriptor, using the platform's java.nio.charset.Charset#defaultCharset() default charset .

Usage

From source file:com.thinkit.operationsys.util.FileUtil.java

public static void copyFile(String src, String dest) {
    System.out.println("copy");
    File f1 = new File(src);
    File f2 = new File(dest);
    //int b=0;//from  w w w  .  ja  v  a2  s .  c o  m
    String line = "";
    try {
        FileReader reader = new FileReader(f1);
        FileWriter writer = new FileWriter(f2);
        BufferedReader br = new BufferedReader(reader);
        BufferedWriter bw = new BufferedWriter(writer);
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        reader.close();
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

}