Wednesday, July 16, 2014

First Class Function in Java

Java 8 has many features. One of most important feature is First class Function

The core idea of the concept is use the function as Parameter in any other function

below code explains the First class function concept;

//---------------------------------

File[] fil_dir=new File("d:").listFiles(new FileFilter() {

             @Override
             public boolean accept(File file{
                 file.isHidden();
             }
         });

        System.out.println(fil_dir.length);

the above program is used to find the hidden files in directory. Here we applying the filter class which is Anonymous Inner class  . The above code can be re-written as below using first class function concept
//------------------------------------

File[] fil_dir=new File("d:").listFiles(File::isHidden());

        System.out.println(fil_dir.length);

File::isHidden() - this code acts as first class function in listFiles method.
The syntax for applying first class function in java is  ClassName :: MethodName 


Sunday, September 29, 2013

Apache PDFBox - A Java PDF Library

The Apache PDFBox™ library is an open source Java tool for working with PDF documents. This project allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents. Apache PDFBox also includes several command line utilities. Apache PDFBox is published under the Apache License v2.0.