Java provides a new interface named Predicate which is a functional interface. A functional interface is an interface which will have exactly one abstract method in addition to one or more default methods. In the case of Predicate interface, the abstract method is test method whose signature is as shown below boolean test(T t) In…… Continue reading Java Predicate
Category: Core
PushBackReader Demo
This post explains PushBackReader class in java. This reader allows us to put the data read from the input stream back into the stream and reread it again. The below explains how to use it Main Class package IO; import java.io.PushbackReader; import java.io.StringReader; public class PushBackReaderDemo { public static void main(String[] args) throws Exception {…… Continue reading PushBackReader Demo
Creating dynamic proxy objects
This post explains how to create proxy objects using Java Proxy api. We need the below items to create a proxy. 1) proxy interfaces (list of interfaces the dynamic proxy class will implement). 2) dynamic proxy class is proxy class generated at runtime and implements the proxy interfaces. 3) proxy instance is an instance of…… Continue reading Creating dynamic proxy objects
How to use SequenceInputStream
SequenceInputStream reads data from multiple inputstreams in an order. It starts with first inputstream and once it is done reading the first inputstream, it starts reading data from the next available inputstream. Two constructors are available for creating an instance of this stream. First one being SequenceInputStream(InputStream s1, InputStream s2) The above constructors limits us…… Continue reading How to use SequenceInputStream
LineNumberReader class setLineNumber method
As mentioned in Java API, LineNumberReader class keeps track of line number and return line number in addition to the data read. In this post I will mainly cover setLineNumber method in the class. The api document doesn’t clearly mention its purpose. The setLineNumber can be used for two purposes 1) Reset the line number…… Continue reading LineNumberReader class setLineNumber method