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

net.sf.jtables.io.WriterTableObjectToRowsAbstract Maven / Gradle / Ivy

Go to download

Simple and lightweight framework to work with tables and table based files such as CSV and other (tab)-delimited files.

There is a newer version: 2.2.2
Show newest version
package net.sf.jtables.io;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public abstract class WriterTableObjectToRowsAbstract extends WriterTableString {
	
	public WriterTableObjectToRowsAbstract(File file) throws IOException {
		super(file);
	}

	public WriterTableObjectToRowsAbstract(OutputStream stream) {
		super(stream);
	}

	public WriterTableObjectToRowsAbstract(Writer writer) {
		super(writer);
	}

	public WriterTableObjectToRowsAbstract writeElement(T element) throws IOException {
		writeElement(DEFAULT_DELIMITER, element);
		return this;
	}
	
	public WriterTableObjectToRowsAbstract writeElements(Collection elements) throws IOException {
		writeElements(DEFAULT_DELIMITER, elements);
		return this;
	}
	
	public WriterTableObjectToRowsAbstract writeElements(String delimiter, Collection elements) throws IOException {
		Iterator it = elements.iterator();
		while(it.hasNext()){
			writeElement(delimiter, it.next());
			if(it.hasNext()){
				super.writer.newLine();
			}
		}
		return this;
	}
	
	public abstract WriterTableObjectToRowsAbstract writeElement(String delimiter, T element) throws IOException;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy