BiConsumer Example

In this post, I will show how to use BiConsumer functional interface with an example. BiConsumer functional interface is similar to Consumer functional interface. It takes an input, processes it and doesn’t return anything. The difference lies in the number of inputs taken by the BiConsumer functional interface. Consumer functional interface takes one input whereas…… Continue reading BiConsumer Example

BiFunction Example

In this post, I will show how to use BiFunction functional interface with an example. BiFunction functional interface is similar to Function functional interface. It takes an input and produces an output. The difference lies in the number of inputs taken by the BiFunction functional interface. Function functional interface takes one input and produced one…… Continue reading BiFunction Example

DigestInputStream Class Example

In this post under Java –> Security, I will explain with example the use of DigestInputStream class. When any stream class under java.io package is used, the data flows from source to destination in a stream. DigestInputStream class can be used to calculate a Message Digest when data is being read from a source using…… Continue reading DigestInputStream Class Example

DigestOutputStream Class Example

In this post under Java –> Security, I will explain with example the use of DigestOutputStream class. When any stream class under java.io package is used, the data flows from source to destination in a stream. DigestOutputStream class can be used to calculate a Message Digest when data is being written to the destination using…… Continue reading DigestOutputStream Class Example

Java Util Logging ErrorManager example

In this post under java logging, I will explain the purpose of ErrorManager and how we can use it. Whenever we write the below code logger.info(“Hello my name is Sumanth1”); We are requesting the Handler to log the message to a destination. What if an error happens at the Handler level when an attempt is…… Continue reading Java Util Logging ErrorManager example

Combining two or more Function functional interface

In this post, I will explain how to combine Function functional interfaces. They are two ways in which we can combine Function functional interface and it is achieved using two methods in Function interface as mentioned below 1) default Function andThen(Function after) 2) default Function compose(Function before) Both the methods accept an implementation of Function…… Continue reading Combining two or more Function functional interface

Unzipping a jar file programmatically

In this post, I will explain how to unzip a jar file. Below is the complete code to unzipping a jar file programmatically Main code 1 package jar; 2 3 import java.io.File; 4 import java.io.FileOutputStream; 5 import java.io.IOException; 6 import java.io.InputStream; 7 import java.util.Enumeration; 8 import java.util.jar.JarEntry; 9 import java.util.jar.JarFile; 10 11 public class JarDemo2…… Continue reading Unzipping a jar file programmatically

Function functional interface

In this post, with an example I will show how to use Function functional interface. Function interface is a functional interface that takes an input and produces an output. This is achieved by its “apply” method. Below is an example Main Code 1 package function; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 import java.util.function.Function;…… Continue reading Function functional interface