How to handle Java Exception

We had introduced JavaException in 2 articles: Understand Java Exception & The effect to Java Program (Single & Multi Thread) & How to work with Java Custom Exception. In the tutorial, JavaSampleApproach will guide how to handle Java Exception.
Related post:
How to use Spring Exception Handler for SpringMVC: @ExceptionHandler, @ResponseStatus, @ControllerAdvice

[Continue reading…] “How to handle Java Exception”

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

In the tutorial, JavaSampleApproach will introduce Java Exception and its effect to program’s execution in Single & Multi Thread Program.
Related post:
Java 7 – try-with-resources Statement
How to handle Java Exception

[Continue reading…] “Understand Java Exception & The effect to Java Program (Single & Multi Thread)”

How to write Text File in Java by BufferedWriter

Java provides a BufferedWriter for writting content to File with high performance when performing with large number of write action. Because BufferedWriter decreases I/O interaction by using internal buffer to write data into File.
Related posts:
1. Java Read Text File by BufferedReader, Java 7,Java 8
2. How to delete non-empty Folder in Java

[Continue reading…] “How to write Text File in Java by BufferedWriter”

How to delete non-empty Folder in Java

Java supports a function: java.io.File.delete() to delete a File or an empty directory. But with non-empty folders, we need to implement function to delete them. In the tutorial, JavaSampleApproach will show you how to develop a recursive funtion to delete non-empty Folder.

[Continue reading…] “How to delete non-empty Folder in Java”

How to use Java 8 Encode (Decode) an Image to Base64

For some purpose like transfering an image through RestfulAPI or saving an image to a DataBase, We need Encoder (Decode) the image to Base64. In the tutorial, JavaSampleApproach will guide you how to use Java 8 for converting.

Related post: Java 8 Base64

[Continue reading…] “How to use Java 8 Encode (Decode) an Image to Base64”

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 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”

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”

Gson to convert Java Object to/from Json

The tutorial guides you how to convert Java Object to Json and vice-versa by Gson.

Related Articles:
Jackson to convert Java Object to/from Json String
How to convert Java Object into/from XML – with Castor & Spring Boot

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