Convert String to InputStream in Java

In this post we will provide an example of how to convert a String to InputStream in Java. Convert String to InputStream in Java The following example uses the standard JDK libraries.

The example above convert the String to an InputStream. This is done using the ByteArrayInputStream which is a subclass of InputStream. The … Continue reading Convert String to InputStream in Java

Spring Boot Hello World Example

In this post we will provide a basic example of how to get started using Spring Boot, with a Spring Boot Hello World Example. Setup: First, create a new maven project with the following content in your pom file.

Replacing the groupId, artifactId and version as needed. You can create the following package structure … Continue reading Spring Boot Hello World Example

Java 8 stream allMatch, noneMatch and anyMatch examples

In this post we will provide three examples on how to use the java 8 stream allMatch, noneMatch and anyMatch methods. Java 8 stream allMatch, noneMatch and anyMatch examples: Stream allMatch() Example: The allMatch() method is used on a stream to determine, if all the values satisfy a certain condition(predicate). The example below, checks to … Continue reading Java 8 stream allMatch, noneMatch and anyMatch examples

Basic HttpClient Configuration Example

In this post we will provide a basic HttpClient configuration example. The example will configure different timeout values along with connection pool management. HttpClient configuration example: The example below configures a HttpClient object. The configuration details is as follows: RequestConfig: This object is an immutable class which encapsulates request configuration items. RequestConfig.setConnectionRequestTimeout(): Timeout in milliseconds … Continue reading Basic HttpClient Configuration Example

What is a NullPointerException in Java

In this post we will explain what is a NullPointerException in Java, and how to fix these issues. What is a NullPointerException in Java An application will throw a null pointer exception when you are invoking a method on an object who's value is null. Lets have a look at the example below.

Running … Continue reading What is a NullPointerException in Java

Convert an Object to a Map in Java

In this post we will provide an example on how to convert an object to a map in Java. Setup: You will need to include the following dependency

Convert an Object to a Map in Java: The example below uses a User object which has the following properties Name Age Address (which is another … Continue reading Convert an Object to a Map in Java