I am going to divide this post into following topics for ease of understanding to the readers: What is a WebSocket? JavaEE 7 Support for creating WebSocket end points Javascript support to create WebSocket client end point What is a WebSocket? It is a feature being introduced as part of the HTML5 specification. It introduces …
Asynchronous Servlet – A new feature in Servlet 3.0 and Java EE 6
When Java EE 6 was announced with a new servlet specification i.e Servlet 3.0 – Asynchronous servlet was a very important feature added to the new specification. Suppose your servlet does a long running task like making a JDBC call or invoking a web service, such operations generally take up a lot of CPU time …
Book Review: Pro Java 7 NIO.2
The Pro Java 7 NIO.2 book is all about the latest enhancements to the File NIO APIs added as part of Java 7. The book covers New Path and Paths API: A brief overview of the Path and Paths classes and how these can be used to represent a file/directory. Also explained are the different …
Reading file asynchronously in Java
We all are familiar with reading/writing file in a synchronous way. In Java 7 a new API was added to read/write the contents of the file asynchronously. The API is AsynchronousFileChannel. also read: Java 7.0 Tutorials New Features in Java 7.0 G1 Garbage Collector in Java 7.0 In this example lets look at how to …
How to use Socket API for creating Client-Server application in Java
In this example we make use of ServerSocketChannel and SocketChannel to create a simple Echo application where in the Server would print the data sent by the client. also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials The code is explained with the required comments: and the client which connects …
How to use ByteBuffer in Java?
ByteBuffer API has been in Java since 1.4. The name itself suggests that these contain bytes of data. The data to be stored in the buffer can be Integer (int, long), Characters (char), Floating value (double), all these are converted into bytes before being stored in the buffer array. ByteBuffer can be of two types- …
Lazy Initialization, Singleton Pattern and Double Checked locking
Lazy Initialization Lazy Initialization is a technique where one postpones the instantiation of a object until its first use. In other words the instance of a class is created when its required to be used for the first time. The idea behind this is to avoid unnecessary instance creation. But there are concerns related to …
Visiting all the files and directories for a directory in Java using NIO2
At times we might want to search for some file in a directory traversing recursively into other directories with in that directory, I know getting the recursive program right at the first time is always a challenge. Or we might want to list all the contents of a directory. For all these operations the NIO2 …