//DeleteFiles.java
package step3;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class DeleteFiles {
    public static void start() throws IOException {
        StringBuilder data = new StringBuilder("");
        /********** Begin *********/
        // 读取readme.txt文件
        FileReader sourcesReader = new FileReader("src/step3/readme.txt");
        int read;
        while ((read = sourcesReader.read()) != -1) {
            data.append((char) read);
        }
        sourcesReader.close();
        // 写入readmeCopy.txt文件
        File goal = new File("src/step3/readmeCopy.txt");
        FileWriter goalWriter = new FileWriter(goal);
        goalWriter.write(data.toString());
        goalWriter.close();
        // 删除readme.txt文件
        File deleteSources = new File("src/step3/readme.txt");
        deleteSources.delete();
        /********** End *********/
    }
}
