read the contents of csv file as Map>

  • 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
  • 26
    Jun

    get number of rows in csvDataFile

    /* * Get number of rows in a CSV File Input: CSVFileName Output: integer * numberOfRows or 0 if only header is found */ public int getNumberOfRows(String fileName) {...

    Read More
  • 26
    Jun

    get headers of a csv file as list output

    /* * Get headers of a csv file as list output */ public List<String> getHeaders(String fileName) { List<String> headers = new ArrayList<String>(); try (BufferedReader csvDataFromFile = new BufferedReader(new FileReader(fileName)))...

    Read More
  • 26
    Jun

    get column header’s position in CSV File

    /* * Get header position in CSV File Input: CSV File Name, Header name Returns * HeaderPosition (index of 0 to n) or 999 if no match found */...

    Read More
  • 26
    Jun

    Get number of columns in a CSV File

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

    Read More
  • 26
    Jun

    Equivalent of equalsIgnoreCase for java

    String strText1 = “Admin”; String strText2 = “User Name: adMin”; System.out.println(strText2.toLowerCase().contains(strText1.toLowerCase())); System.out.println(strText1.toLowerCase().contains(strText2.toLowerCase()));   =================== output: true false

    Read More
  • 26
    Jun

    working with custom exceptions

    sample code to implement your custom exceptions and use them in your programs Custom exceptions declaration: ========================================= package CustomExceptions; class MyException extends Exception { public MyException(String s) { super(s);...

    Read More
  • 09
    Jan

    Initializing iOS or Android drivers

    public static Appiumdriver driver; AppiumServiceBuilder serviceBuilder = new AppiumServiceBuilder().usingAnyFreePort(); service=AppiumDriverLocalService.buildService(serviceBuilder); service.start(); driver = (isTargetAndroid()) ? getAndroidDriver(service.getUrl(), false, false) : getIOSDriver(service.getUrl(), false, false); where isTargetAndroid() is a private method in...

    Read More