java

  • 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