Saturday 7 October 2017

CSV Comparision


Here is the explanatory video and following method :




public class compareCSV {

/**
* @param args
* @throws IOException
         * @author : Aman Saraf Jain
*/
public static void main(String[] args) throws IOException {

HashSet<String> f1 = new HashSet<String>(FileUtils.readLines(new File("C:\\Users\\Aman\\Desktop\\demo\\1.csv")));
HashSet<String> f2 = new HashSet<String>(FileUtils.readLines(new File("C:\\Users\\Aman\\Desktop\\demo\\2.csv")));
f1.removeAll(f2); // f1 now contains only the lines which are not in f2

System.out.println(f1.toString());

}

}

Saturday 22 April 2017

Use of Log4j in your Java Program


Download Sample Project from here.

Steps to use log4j :

1.) Download log4j dependency.(included in sample project)
2.) Download log4j.properties (included in sample project)

Create Java Program:

package com.asj;

import org.apache.log4j.Logger;

public class LoggerDemo {
/**
* @created by Aman
*/
public static Logger logger = Logger.getLogger(LoggerDemo.class);

public static void main(String[] args) {
logger.info("Hello!! you are in info log");

logger.warn("Hello!! you are in warn log");

logger.error("Hello!! you are in error log");

logger.debug("Hello!! you are in debug log");
}

}