Use streams.

Remove unused imports.
This commit is contained in:
Gary Gregory 2021-07-06 09:35:44 -04:00
parent 9de125e4f1
commit 589f822445
2 changed files with 4 additions and 7 deletions

View File

@ -102,9 +102,7 @@ public final class CSVPrinter implements Flushable, Closeable {
// It seems a pain to have to track whether the header has already been printed or not.
if (format.getHeaderComments() != null) {
for (final String line : format.getHeaderComments()) {
if (line != null) {
this.printComment(line);
}
this.printComment(line);
}
}
if (format.getHeader() != null && !format.getSkipHeaderRecord()) {
@ -195,7 +193,7 @@ public final class CSVPrinter implements Flushable, Closeable {
* If an I/O error occurs
*/
public void printComment(final String comment) throws IOException {
if (!format.isCommentMarkerSet()) {
if (comment == null || !format.isCommentMarkerSet()) {
return;
}
if (!newRecord) {

View File

@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.stream.Stream;
@ -271,12 +270,12 @@ public final class CSVRecord implements Serializable, Iterable<String> {
if (getHeaderMapRaw() == null) {
return map;
}
for (final Entry<String, Integer> entry : getHeaderMapRaw().entrySet()) {
getHeaderMapRaw().entrySet().forEach(entry -> {
final int col = entry.getValue().intValue();
if (col < values.length) {
map.put(entry.getKey(), values[col]);
}
}
});
return map;
}