Thursday, February 24, 2011

increment a value using jstl c tag

<c:set var="numberOfRows" value="0"/><c:set var="numberOfRows" value="${numberOfRows+1}"/>
<c:out value="${numberOfRows}"/>

Wednesday, February 16, 2011

Read data from file using apache commons.io

package com.jijo;
import org.apache.commons.io.FileUtils;
import java.io.File;
//use commons-io-1.3.2.jar 
//download the above jar and include that in your class path.

class FileTest{

public String getFileData(String fileName){ //eg: c:/jijo/test.txt
String xmlData = null;
File file = new File(fileName);
        try{
        xmlData = FileUtils.readFileToString(file);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
return xmlData;
}

}

Code Complete: A Practical Handbook of Software Construction

Visualage for Java Enterprise Edition