Thursday, 22 June 2017

How to Convert JSON data from file to ArrayList?

In below example file student_data.txt having collections of students data in JSON form and through these Jacson API’s will convert JSON data to ArrayList java object.


Add below jackson-databind-2.8.5.jar in your classpath or make dependency entry in pom.xml file.

Wednesday, 21 June 2017

Java 8 New Features : Lambda Expressions, Optional Class, Defender Methods With Examples

Java 8 is already released by Oracle last year. It is the most feature rich update then the previous version 6 and 7 , which both were somehow minor updates .

The major features of the java 8 are as follows :
  1. Introduction of Optional
  2. Defender Methods
  3. Lambda Expressions

Tuesday, 20 June 2017

Threads, Lifecycle Explained With Example

What is Thread ?

Thread is a sequence of code executed independently with other threads of control with   in a single executed program .

for example : Here we are going to calculate the sum of next hundred numbers from the given input number by the user.

Monday, 19 June 2017

6 Difference between forward() and sendRedirect() in Servlet - Java

Servlet in JEE platform provides two methods forward() and sendRedirect() to route an HTTP request to another Servlet for processing. Though, both are used for forwarding HTTP requests for further processing there are many differences between forward() and sendRedirect() method e.g. forward is performed internally by Servlet, but a redirection is a two-step process, where Servlet instruct the web browser (client) to go and fetch another URL, which is different from the original. That's why forward() is also known as a server-side redirect and sendRedirect() is known as the client-side redirect. Becuase of their usefulness, the difference between forward() and sendRedirect is also a frequently asked Servlet interview question.

Thursday, 15 June 2017

How to unzip files from zip file by java?

In Java package provide below classes and api’s to convert files to zip file.

ZipInputStream: This class implements an input stream filter for reading files in the ZIP file format.

ZipEntry: Class is used for zip entry.

In below example will show to unzip files from a zip file  and store in folder