import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
public class TestWriter {
public static void main(String[] args) {
File file01 = new File("test01.txt");
File file02 = new File("Copytest01.txt");
Reader reader = null;
Writer writer = null;
try
{
reader = new FileReader(file01);
writer = new FileWriter(file02);
char[] flush = new char[1024];
int len = -1;
while((len = reader.read(flush))!=-1)
{
writer.write(flush, 0,len);
}
writer.flush();
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally
{
if(writer != null)
{
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(reader != null)
{
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}