@@ -0,0 +1,1796 @@
+package us.codecraft.webmagic.pipeline;%0A%0Aimport org.apache.commons.codec.digest.DigestUtils;%0Aimport org.apache.commons.lang3.builder.ToStringBuilder;%0Aimport org.apache.log4j.Logger;%0Aimport us.codecraft.webmagic.Task;%0Aimport us.codecraft.webmagic.model.HasKey;%0Aimport us.codecraft.webmagic.model.PageModelPipeline;%0Aimport us.codecraft.webmagic.utils.FilePersistentBase;%0A%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0A%0A/**%0A * Store results objects (page models) to files in plain format.%3Cbr%3E%0A * Use model.getKey() as file name if the model implements HasKey.%3Cbr%3E%0A * Otherwise use SHA1 as file name.%0A *%0A * @author code4crafter@gmail.com %3Cbr%3E%0A * @since 0.2.2%0A */%0Apublic class FilePageModelPipeline extends FilePersistentBase implements PageModelPipeline %7B%0A%0A    private Logger logger = Logger.getLogger(getClass());%0A%0A    /**%0A     * new JsonFilePageModelPipeline with default path %22/data/webmagic/%22%0A     */%0A    public FilePageModelPipeline() %7B%0A        setPath(%22/data/webmagic/%22);%0A    %7D%0A%0A    public FilePageModelPipeline(String path) %7B%0A        setPath(path);%0A    %7D%0A%0A    @Override%0A    public void process(Object o, Task task) %7B%0A        String path = this.path + %22/%22 + task.getUUID() + %22/%22;%0A        try %7B%0A            String filename;%0A            if (o instanceof HasKey) %7B%0A                filename = path + ((HasKey) o).key() + %22.html%22;%0A            %7D else %7B%0A                filename = path + DigestUtils.md5Hex(ToStringBuilder.reflectionToString(o)) + %22.html%22;%0A            %7D%0A            PrintWriter printWriter = new PrintWriter(new FileWriter(getFile(filename)));%0A            printWriter.write(ToStringBuilder.reflectionToString(o));%0A            printWriter.close();%0A        %7D catch (IOException e) %7B%0A            logger.warn(%22write file error%22, e);%0A        %7D%0A    %7D%0A%7D%0A

add FilePageModelPipeline