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

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

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

import java.io.*;
import java.util.Collections;
import java.util.List;

/**
 * @author : wangqijia
 * create at:  2021/10/31  下午11:18
 */
public abstract class AbstractStreamViewer implements Viewer, Closeable {

    protected Writer writer;

    protected AbstractStreamViewer(OutputStream outputStream) {
        this.writer = new BufferedWriter(new OutputStreamWriter(outputStream));

    }

    protected AbstractStreamViewer(Writer writer) {
        this.writer = writer;
    }

    @Override
    public void outPut(String content) {
        batchOutPut(Collections.singletonList(content));
    }

    @Override
    public void batchOutPut(List contentList) {
        try {
            for (String content : contentList) {
                writer.write(content + "\n");
            }
            writer.flush();
        } catch (IOException e) {
            throw new ViewOutputException("output view exception", e);
        }
    }

    @Override
    public void close() throws IOException {

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy