All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rrsunhome.excelsql.viewer.FileViewer Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package com.github.rrsunhome.excelsql.viewer;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.List;

/**
 * @author : qijia.wang
 * create at:  2020/3/31  下午3:45
 */
public class FileViewer implements Viewer {

    private Writer writer;

    public FileViewer(String outPutPath, boolean append) {
        try {
            this.writer = new FileWriter(outPutPath, append);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public FileViewer(String outPutPath) {
        this(outPutPath, false);
    }

    @Override
    public void outPut(String content) {
        outPut(Arrays.asList(content));
    }

    @Override
    public void outPut(List contentList) {
        try {
            for (String content : contentList) {
                writer.write(content + "\n");
            }
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy