In this post under Lombok, I will explain with example the purpose of “@Cleanup” annotation. In Java whenever we open a resource, we have to close it after we are done with the resource. Usually all resource will have “close” method. We call that “close” method to close the resource. To do this in Java,…… Continue reading @Cleanup annotation example
assertArraysEquals example
In this post under Junit 5, I will explain with example the purpose of “assertArraysEquals” method. We can use the “assertArraysEquals” method to assert whether two arrays are equal or not. Below is the complete main code for your reference. Main Class package package15;import static org.junit.jupiter.api.Assertions.assertAll;import static org.junit.jupiter.api.Assertions.assertArrayEquals;import org.junit.jupiter.api.Test;public class Example15 { @Test public void…… Continue reading assertArraysEquals example
InstanceCreator example
In this post under Gson, I will show with example the purpose of “InstanceCreator” interface provided by Gson framework. Whenever we define a Pojo class, we don’t add constructor of our own, as we use Java provided default no argument constructor to create an object of the class. But sometimes we end up adding constructors…… Continue reading InstanceCreator example
Merging text files
In this post under Java I will with example how to merge two or more text files. Below is the complete code for your reference Main class 1 package io;2 3 import java.io.*;4 5 public class IOExample3 {6 private static int BYTES_TO_BE_READ = 1000;7 private char buffer[] = new char[BYTES_TO_BE_READ];8 9 public static void main(String[]…… Continue reading Merging text files
Creating text file of user specified size with random data
In this post under Java, I will show with example how to create a text file of user specified size with random data. Below is the complete code for you example Main class 1 package io;2 3 import java.io.BufferedWriter;4 import java.io.File;5 import java.io.FileWriter;6 import java.io.IOException;7 import java.util.Random;8 9 public class IOExample1 {10 private Random random;11…… Continue reading Creating text file of user specified size with random data
MaxWait duration property
In this post under Apache Pool, I will explain with example the purpose of “MaxWait” duration property. This property is used in conjunction with “BlockWhenExhausted” property explained in previous post. This property works only when “BlockWhenExhausted” is set to “true”. When “BlockWhenExhausted” is set to true and the caller tries to get idle objects more…… Continue reading MaxWait duration property
BlockWhenExhausted Pool Property
In this post under Apache Pool, I will explain with example the purpose of “BlockWhenExhausted” property of an Object Pool. Lets say we have 3 idle objects in the object pool and the caller code retrieves all the 3 objects. As a result of which the pool will be empty i.e., no idle objects will…… Continue reading BlockWhenExhausted Pool Property
Object Pools object retrieval strategy
In this post under Apache Pool, I will explain Apache Pool’s object retrieval strategy with example. Whenever we request an object from an object pool, by default it follows LIFO (Last In First Out) strategy, to retrieve an idle object. For example if in a pool, object are added in the below order and all…… Continue reading Object Pools object retrieval strategy
Setting headers example
In this post under Spring WebClient, I will explain with example how to set headers before making a HTTP call. Below is the complete code for your reference Main class 1 package defaultPackage; 2 3 import org.springframework.web.reactive.function.client.ClientResponse; 4 import org.springframework.web.reactive.function.client.WebClient; 5 6 import reactor.core.publisher.Mono; 7 8 public class Example5 { 9 public static void main(String[]…… Continue reading Setting headers example
Setting accept header example
In this post under Spring WebClient, I will explain with example how to set “ACCEPT” header before sending an HTTP GET request. Below is the complete main code for your reference. Main class 1 package defaultPackage; 2 3 import org.springframework.http.MediaType; 4 import org.springframework.web.reactive.function.client.ClientResponse; 5 import org.springframework.web.reactive.function.client.WebClient; 6 7 import reactor.core.publisher.Mono; 8 9 public class Example6…… Continue reading Setting accept header example