public class PrintForeachAction<K,V> extends Object implements ForeachAction<K,V>
Constructor and Description |
---|
PrintForeachAction(PrintWriter printWriter,
KeyValueMapper<? super K,? super V,String> mapper,
String label)
Print customized output with given writer.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(K key,
V value)
Perform an action for each record of a stream.
|
void |
close() |
public PrintForeachAction(PrintWriter printWriter, KeyValueMapper<? super K,? super V,String> mapper, String label)
System.out
and the others. If the PrintWriter is PrintWriter(System.out)
,
then it would close System.out
output stream.
Afterall, not to pass in PrintWriter(System.out)
but null
instead.
printWriter
- Use System.out.println
if null
.mapper
- The mapper which can allow user to customize output will be printed.label
- The given name will be printed.public void apply(K key, V value)
ForeachAction
apply
in interface ForeachAction<K,V>
key
- the key of the recordvalue
- the value of the recordpublic void close()