Creating a YAML file

The below post explains how to write YAML data to file using YAMLGenerator. YAMLGenerator writes the data to a file in streaming way, helping the developer using the api to avoid creating an object representation of the entire data. We can get an instance of YAMLGenerator with the help of an instance of YAMLFactory as…… Continue reading Creating a YAML file

Parsing a YAML file

In this post I will explain how to parse a YAML file using Jackson framework. We need the following jars in our classpath 1) jackson-dataformat-yaml-2.9.6.jar 2) snakeyaml-1.18.jar 3) jackson-annotations-2.9.0.jar 4) jackson-core-2.9.6.jar 5) jackson-databind-2.9.6.jar First we need to create an instance of YAMLFactory class. It is factory class used to create instance of YAMLParser (reader) and…… Continue reading Parsing a YAML file

Writting to multiple files using MultiResourceItemWriter

In this post of Spring Batch, I will explain how to write the records read, to multiple files instead of one. We take the help of MultiResourceItemWriter, it writes to multiple file and suffixes the output fileNames with an index. For example if the file name to be created, is DemoData.txt and two files are…… Continue reading Writting to multiple files using MultiResourceItemWriter

Filtering items using ItemProcessor

In Spring Batch, items are read from the source using reader and written to destination using a writer. Sometimes, we need to add business logic between the reader and writer for the following purpose1) Filtering an item2) Converting an item read from one format to another before written to the destination3) Modify the item read…… Continue reading Filtering items using ItemProcessor

Combining two or more Consumer Functional Interface

In this post I will explain how to combine two or more Consumer Functional interface implementations. Consumer Functional interface has a default method “andThen”, which combines two Consumer Functional interface implementations. The method signature is as shown below default Consumer andThen(Consumer after) The way two Consumer implementations are combined using “andThen” method is as shown…… Continue reading Combining two or more Consumer Functional Interface

Map with Composite key

In Maps we always use one key object to uniquely identify an entry. We never combined a collection of keys to create one composite key and use it to uniquely identify an entry. But with help of MultiKey class available in Apache Common Collections framework, we can create a composite key to uniquely identify an…… Continue reading Map with Composite key