Precise rounding of decimals using Rounding Mode Enumeration


The Rounding Mode Enum in java.math package is used to perform precise rounding of decimal values. It was introduced in Java 5.0. This Enum provides various constants each of which is used for different modes of rounding. The decimal value would be rounded off to the number of decimal places based on the scale that […]

Using the Prototype pattern to clone objects


Prototype pattern is one of the creational patterns that concentrate on duplicating objects if needed. Assuming that we are in process of creating a template. Most of the times, we copy an existing template, do some changes in it and then will use it. Technically, we make a copy of the source, make some changes […]

How to send mail using Java Mail API?


The Java Mail API provides support for sending and receiving electronic mail messages. The API provides a plug-in architecture where vendor’s implementation for their own proprietary protocols can be dynamically discovered and used at the run time. Sun provides a reference implementation and its supports the following protocols namely, also read: Java Tutorials Java EE […]

Passing arguments and properties from command line


Arguments and properties can be passed to a java application from command line. In this techical tip, let us see how to pass arguments as well as properties from command line. also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials Passing arguments from command line The syntax to pass arguments […]

Generation of Random Numbers


Random numbers in java can be generated either by using the Random class in java.util package or by using the random() method in the Math class in java.lang package. also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials In both these approaches, we only get a pseudo random number and […]

Downloading Content from the Internet


Let us write a Simple Downloader in this techincal tip by making use of the classes with package. URL stands for Uniform Resource Locator and it is used to locate a resource in the Web in a standard fashion. A resource in the Web can be anything; it can be as simple as Html […]

Creating user defined exceptions


Though Java provides an extensive set of in-built exceptions, there are cases in which we may need to define our own exceptions in order to handle the various application specific errors that we might encounter. also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials While defining an user defined exception, […]

Copying File Contents using FileChannel


In this technical tip, let us see an easy way of achieving file copy using File Channels. File Channels are part of Java New I/O Packages. A file can be viewed as a sequence of bytes. The various Buffer classes in New I/O Packages serve as a container for manipulating the primitive byte contents. It […]

What is Hibernate Caching?


1. Introduction While working with Hibernate web applications we will face so many problems in its performance due to database traffic. That to when the database traffic is very heavy . Actually hibernate is well used just because of its high performance only. So some techniques are necessary to maintain its performance. Hibernate Caching is […]

Logging Messages using Java Logging API


The Logging API in Java enables Applications to log messages of some level which will be very useful for debugging purpose. Say, if a system fails for some reasons, then the reason can be easily traced out by looking at the information available in the log file. In this section, let us see an overview […]