Create simple XML files with Freemarker Template (ftl)

Freemarker is an open source java template engine which can be used to create text outputs in different formats. (HTML to auto generated source code).
It suitable if you have a MVC pattern in your dynamic web project to use this kind of template engine. (JSTL Tag also can provide this kind of features).

In this post I will show you how to create easily XML files using Freemarker FTL templates. (FTL is the template files of Freemarker.)

 

Continue reading “Create simple XML files with Freemarker Template (ftl)”

How to traverse through the files in given directory – Java

In Java 1.6

We don’t need to use external libraries java.io.File package enough to visit files in a directory.

Here is the implementation sample :

public void visitFiles(File node) {

   if (!node.isDirectory()) {
      System.out.println("File Name : "+ node.getName());
   }
   if (node.isDirectory()) {
      String[] subNote = node.list();
      for (String filename : subNote) {
         visitFiles(new File(node, filename));
      }
   }
}

In Java 1.7

Java 1.7 has a new library for file operations. java.nio.file.  This new library provides walkFileTree functionality to avoid recursive usage of 1.6 File library.

Continue reading “How to traverse through the files in given directory – Java”