Tag «Java»

How to validate date using Java regular expression

My earlier post on how to validate email address, SSN and phone number validation using Java regex still attracts a lot of visitors. Today I realized that another piece of data that many programmers need to validate is the date. Many Java applications have to process input date values, so I thought it will be …

Ultimate Java Regular Expression to validate any email address.

My post about Java regular expression gets a lot of hits daily. Someone commented that the regular expression I included in that post does not block certain invalid email addresses. So I updated the Java regular expression to validate email address. I am pretty sure that the following Java regular expression will validate any email …

How to configure multiple handlers in a Spring MVC web application

In Spring MVC, DispatcherServlet relies on handler mapping to determine which controller the request should be sent to. All handler mapping classes in Spring implement org.springframework.web.servlet.HandlerMapping interface. Spring distribution contains following four implementation of HandlerMapping interface. BeanNameUrlHandlerMapping SimpleUrlHandlerMapping ControllerClassNameHandlerMappign CommonsPathMapHandlerMapping BeanNameUrlHandlerMapping is the simplest of all and DispatcherServlet looks for this mapping by default. You …

Import static elements for more readable Java code

One of the welcome additions to Java language in Java 5 release is the static import declaration. static import works in the same way as traditional import declaration but it imports only the static members of a class. Traditional import declaration looks like this import java.util.*; The above statement will import all the classes under …

How to read properties file in Java.

Reading properties file in Java is much easier than you might have thought. Following example illustrates one simple way of reading properties from a properties file. Let’s say we need to read from myConfig.properties file. The properties file has following entries. Directory = C:/prodFiles/ NumberOfFiles = 25 Extension = java Here is the java code …

Automatically Sort Vector Elements

Vector class in java.util package is very easy to use. You can add objects of any type in a vector. You don’t have to worry about declaring the size of the vector. You can just keep adding elements to your object and the vector will dynamically adjust the size. The vector will add elements one …

#1 Programming Language – Java

According to TIOBE Programming Community Index Java is still the #1 programming language. TIOBE Index gives an indication of the popularity of a programming language and is updated monthly. The ratings are calculated by counting hits of the most popular search engines. Ruby moved up from 13th to 10th position. Following is the list of …