Deserializing YAML data to Java object

In this post under YamlBeans, I will show with an example of how to deserialize a YAML data to Java object. Main Code 1 import java.io.File; 2 import java.io.FileReader; 3 import java.io.IOException; 4 5 import com.esotericsoftware.yamlbeans.YamlReader; 6 7 public class YamlDemo2 { 8 public static void main(String[] args) { 9 File file = new File(“input1.yml”);…… Continue reading Deserializing YAML data to Java object

Skipping records during record reading, processing or writing

While reading a record from a file, processing already read record, or writing a record to a file, exceptions happens. They are two ways to handle the exceptions 1) skip it and continue with the next record. 2) Stop the processing of entire file. Sometimes the exceptions are not so serious and we can skip…… Continue reading Skipping records during record reading, processing or writing

JCache EternalExpiryPolicy Example

This post explains EternalExpiryPolicy with simple example. EternalExpiryPolicy is an expiry policy used to inform cache to never remove entries in the cache. Below is an example of how to use it. Main Code 1 import java.util.Iterator; 2 3 import javax.cache.Cache; 4 import javax.cache.Cache.Entry; 5 import javax.cache.CacheManager; 6 import javax.cache.Caching; 7 import javax.cache.configuration.Factory; 8 import…… Continue reading JCache EternalExpiryPolicy Example

Serializing Java object to YAML format

In this post under YamlBeans, I will show with an example of how to serialize a Java object to YAML format. Below is the complete code Main Code 1 import java.io.File; 2 import java.io.FileWriter; 3 import java.io.IOException; 4 import java.util.ArrayList; 5 import java.util.List; 6 7 import com.esotericsoftware.yamlbeans.YamlWriter; 8 9 public class YamlDemo1 { 10 public…… Continue reading Serializing Java object to YAML format

Annotation Since and setVersion method

In this post under Gson, I will explain with an example how to use @Since annotation. The @Since annotation is used in combination with “GsonBuilder.setVersion” method. The annotation has no effect if it is not used along with “GsonBuilder.setVersion” method. The @Since annotation is used for the fields of the class and it accepts a…… Continue reading Annotation Since and setVersion method

Annotation Until and setVersion method

In this post under Gson, I will explain with an example how to use @Until annotation. The @Until annotation is used in combination with “GsonBuilder.setVersion” method. The annotation has no effect if it is not used along with “GsonBuilder.setVersion” method. The @Until annotation is used for the fields of the class and it accepts a…… Continue reading Annotation Until and setVersion method