java

  • 22
    Aug

    Configure log4j to write logs to local filesystem – FileAppender

    Three main components that needs to be configured in log4j.properties file are: 1. logger => log messages. 2. appender => specifies the output destination like console or a file....

    Read More
  • 21
    Aug

    How to convert an Array as Map in java

    Following code snippet can be used to convert an Array to Map in java import org.apache.commons.lang3.ArrayUtils; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class ArraysToMap { public static void...

    Read More
  • 20
    Aug

    how to handle Untrusted sites in Selenium webdriver

    // Create DesiredCapabilities class object DesiredCapabilities cap=DesiredCapabilities.chrome(); // Set ACCEPT_SSL_CERTS variable to true cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); // Set the driver path System.setProperty(“webdriver.chrome.driver”,”Chrome driver path”); // Open browser with capability WebDriver...

    Read More
  • 16
    Aug

    Invoke a task every 1 minute

    In order to invoke a task / function periodically (say every one minute) we can use following code snippet. Step 1: Create a class which calls “function” to be...

    Read More
  • 15
    Aug

    Compare maps in java

    Following code snippet can be used to compare two Maps package map; import java.util.HashMap; import java.util.Map; public class ComparingMaps { public static void main(String args) { Map map1 =...

    Read More
  • 17
    Jul

    Read the excel data as HashMap>

    Following code snippet can be used to read an entire Excel file as HashMap import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import...

    Read More
  • 03
    Jul

    Creating a Maven project from Command line

    mvn archetype:generate -DarchetypeArtifactId=maven.archetype.quickstart -DgroupId=org.example -DartifactId=skeleton.web.services -DinteractiveMode=false   mvn spring-boot:run   mvn clean package¬† and java -jar target/skeleton.web.services-1.0-SNAPSHOT.jar  

    Read More
  • 26
    Jun

    read the contents of csv file as Map>

    /* * Read all contents of atmTransactionFile into Map<index, List<String, String>> */ public Map<Integer, List<String>> readCSVFile(String fileName) { int rowdata1= 0; String csvRow = null; List<String> rowData = new...

    Read More
  • 26
    Jun

    get number of columns in a csv file

    /* * Get number of columns in a CSV File Input: CSVFileName Output: integer * numberOfColumns or numberOfHeaders */ public int getNumberOfColumns(String fileName) { int columns = 0; String...

    Read More
  • 26
    Jun

    get row number where first column matches to given value

    /* * Get row number where first column contains specific value */ public int getRowId(String fileName, String valueToSearch) { int rows = 0; String currentRow; try (BufferedReader csvDataFile =...

    Read More