Java 7 – try-with-resources Statement

Java 7 provides a new approach for closing resources with clean & clear code by try-with-resources statment. In the article, JavaSampleApproach will introduce the benifit when programming by try-with-resources statement.

Related Post: Understand Java Exception & The effect to Java Program (Single & Multi Thread)

[Continue reading…] “Java 7 – try-with-resources Statement”

Java 8 Base64

Java 8 Base64 provides a standard way to do Base64 encoding and decoding.
There are three types of Base64 encoding:
Basic: Encoder produces a set of characters within A-Za-z0-9+/. Decoder rejects any character NOT mapped to A-Za-z0-9+/.
URL: Encoder produces a URL or safe filename which is set of characters within A-Za-z0-9+_.
MIME: Output is mapped to MIME friendly format.

[Continue reading…] “Java 8 Base64”

Java 8 Multiple CompletableFutures

In previous posts, we have concept of how to use CompletableFutures. This tutorial is about combining multiple CompletableFutures, it is one of the most important and useful abilities of Java 8 asynchronous processing.

Related articles:
Java Future
CompletableFuture Handle Exception

[Continue reading…] “Java 8 Multiple CompletableFutures”

Java 8 CompletableFuture Handle Exception

Exception handling is important in software development, Java 8 CompletableFuture also provides methods to handle errors when they occurs.

Related article:
Java Future
Java 8 CompletableFuture
Java 8 Multiple CompletableFutures

[Continue reading…] “Java 8 CompletableFuture Handle Exception”

Java 8 CompletableFutures

Java 8 multithreading programming has an important feature named CompletableFuture.
In previous post about Java Future, we have the concept of a Future object, which can help us make something done while waiting for other things. However, although we can inspect Future objects to see if they’re done, what if we wanna execute some code whenever its ready? We still have to wait until the result is available.

CompletableFuture meets the requirement, and more than that.

Related articles:
Java Future
CompletableFuture Handle Exception
Java 8 Multiple CompletableFutures

[Continue reading…] “Java 8 CompletableFutures”

Java Future

In multithreaded programming, Java Future with Callable is very important for tasks which we want to know status and get the returned object.

This article give us an example for how to work with Future and Callable inside.

Related Articles:
Java Thread Pool – ExecutorService
Java 8 CompletableFutures
Java 8 CompletableFuture Handle Exception
Java 8 Multiple CompletableFutures

[Continue reading…] “Java Future”

Jackson to convert Java Object to/from Json String

The tutorial will guide you how to use Jackson for converting Java object to Json and vice-versa.

Related Articles:
Gson for converting Java Object to/from Json
How to convert Java Object into/from XML – with Castor & Spring Boot
How to use @JsonView to serialize/de-serialize and customize JSON format from Java Object.

[Continue reading…] “Jackson to convert Java Object to/from Json String”

Java 8 – Method References

Method References make it clear when referring to the existing method by name.

In the article Lambda Expressions and Functional Interfaces, we use lambda expressions to create anonymous methods and sometimes, calling an existing method is the only thing it does.

When using lambda expression without input arguments or those input arguments doesn’t make sense, we can use Method References to simplify the syntax.

This tutorial introduces four kinds of Method References and how to use them efficiently with some Functional Interfaces.

[Continue reading…] “Java 8 – Method References”

Java 8 – Functional Interfaces

Functional Interfaces is one of the new important things of Java 8. In previous article, we had a little view about common use cases of Lambda Expression including Runnable and ActionListener. They are example of Functional Interfaces.

This tutorial helps you have deeper concept of Functional Interface, then some interfaces which are provided in java.util.function package such as Predicate and Function.

[Continue reading…] “Java 8 – Functional Interfaces”