Archive | August 27th, 2007

Recursively traversing files and folders using Java File API

August 27, 2007

1 Comment

In this section, let us see how to recursively traverse over files and folders by making use of Java File API. Whether it is a folder or a file, both are represented as a java.io.File object. For example, consider the following code snippet, 1 2 File myFile = new File("C:\myDocuments\myFile.txt"); // Case 1 File myFolder [...]

email

Factory pattern – Design Patterns in Java/J2EE

August 27, 2007

5 Comments

Creational pattern deals with the creation of objects and it hides the complex logic involved in the object creation object from the clients. One of the common creational patterns is the Factory pattern and it is used extensively in Applications. Let us understand what factors should be considered in mind while designing a Factory pattern [...]

Conversion between Array and List types

August 27, 2007

0 Comments

In some cases, we may need to convert an array to a list or vice versa. The method asList() is available in the Arrays class, and the toArray() method in list and set classes serve this purpose. The Arrays.asList() method converts an array into a list and the size of the list is fixed. Let [...]