Posts

Showing posts with the label jdk7

All you need to know about JSON Processing in JEE7

JSON is the choice data transfer format used all RESTful services because it is light weight, open standard, less verbose and easy to understand. One of the most important factor for all current generation services is performance and JSON format satisfies all such needs. There are already few third party Java APIs available to JSON parsing but with growing popularity, JEE introduced new JSON processing 1.0 API as part of JSR-353. This API supports both object model as well as streaming model for processing JSON, which are similar to those used for XML documents.This API is limited to JSON processing but not binding, JSON-binding framework will be available in subsequent version of JEE. Object vs Streaming Model : The object model creates a tree that represents the JSON data in memory. The tree can then be navigated, analyzed, or modified. This approach is the most flexible and allows for processing that requires access to the complete contents of the tree. However, it is often sl...

Getting started with Java 7

Recently out product has adapted JDK 7 for development as well as run-time. So get familiar everybody in the team with the new features of JDK , so i prepared a presentation "Getting started with Java 7". Sharing same presentation to refer you haven't still adapted JDK7.  Presentation:

Type Inference in Java

As part of Generics , Java language supports type safe programming. It allows a type or method to operate on objects of various types while providing compile-time type safety. The most common use case is while using Java Collection framework. For example if you define a list of string and trying to add integer value to the list, compiler throws error. List list = new ArrayList(); //Compilation Error : he method add(int, String) in the type List is not applicable for the arguments (int) list.add(10); As a developer you may always notice redundancy in defining parameter type information in both the side of declaration. As off Java 1.6, language doesn’t provide any feature to overcome it. Using Static Factory : One possible way to overcome this problem by using static factory methods. If you frequently use typed list or map in application then you can define generic static factory methods which returns you required typed map or list. public static HashMap getMapInstance(){ ...

FileVisitor from NIO.2 File System API in Java 7

As a part of project Coin ( Language changes ) in Java 7 improved version of file operation APIS has introduced, java.nio.file . There are many new functionalities has been introduced for ease of day to day programming, FileVisitor is one these APIs. As explained above, new interface java.nio.file.FileVisitor has been introduced for traversing the file system. It has methods like preVisitDirectory(), postVisitDirectory() , visitFile () etc to give control to programmer to do any specific task while traversing/visiting the file system. A concrete  implementation java.nio.file.SimpleFileVisitor has been provided those don't want to provide implementation for all of the methods from java.nio.file.FileVisitor . Here is simple example using these new classes.   package com.test.jdk7; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.att...