Posted In: Java Core, String

How to parse a mathematical expression given as a string – using Bean Shell

Evaluating a math expression given in string form Maven beanshell beanshell import package com.example.mathexpression; import org.junit.Test; import bsh.Interpreter; public class MathExpression { @Test public void evaluate1() throws Exception { System.out.println(“\nevaluate1() start”); Interpreter interpreter = new Interpreter(); interpreter.eval(“result = 5+4*(7-15)”); System.out.println(interpreter.get(“result”)); } }

Read More

Tags:

by , on August 30th, 2017

Posted In: Java Core, String

How to read and parse CSV file using Guava Splitter

Splitting a comma-separated string but ignoring commas in quotes Maven guava Guava Splitter Works only without commas in quotes data Works with commas in quotes data

Read More

Tags:

by , on August 29th, 2017

Posted In: Java Core, String

How to read and parse CSV file using String Pattern

Splitting a comma-separated string but ignoring commas in quotes Parsing CSV input with a RegEx in java

Read More

Tags:

by , on August 29th, 2017

Posted In: Java Core, String

How to read and parse CSV file using Open CSV

Splitting a comma-separated string but ignoring commas in quotes Maven opencsv Example csv (cm24AUG2017bhav.csv) Example csv commas in quotes (cm24AUG2017bhav1.csv) opencsv import With deprecated CSVReader. Use CSVReaderBuilder With deprecated CSVReader. Use CSVReaderBuilder. commas in quotes data With CSVReaderBuilder With CSVReaderBuilder. commas in quotes data With CsvToBean and ColumnPositionMappingStrategy. CsvToBean.parse is deprecated With header element name

Read More

Tags:

by , on August 29th, 2017

Posted In: Java Core, String

How to read and parse CSV file using Apache Commons CSV

Splitting a comma-separated string but ignoring commas in quotes Maven commons-csv Example csv Example csv commons csv import With element index With header element name With header name and with commas in quotes With header name RFC4180 format

Read More

Tags:

by , on August 29th, 2017

Posted In: Apache, Spark

How to set up Spark on Windows

There are two options to run Spark. Run it on spark-shell or through Java Code in Eclipse 1. spark-shell – Software required 1. Install JDK 1.8 2. Download spark-2.2.0-bin-hadoop2.7.tgz 3. Download winutils.exe 4. Create /tmp/hive/ folder. 5. Add or set commands 4. Run spark-shell Step 1 – Install JDK and set JAVA_HOME Step 2 – […]

Read More

by , on August 28th, 2017

Posted In: JEE, JSP

How to display UTF-8 characters in JSP

Make sure to have charset=UTF-8 and pageEncoding=”UTF-8″ JSP

Read More

by , on August 27th, 2017

Posted In: JEE, JSP

How to strip whitespace from jsp output

How trimDirectiveWhitespaces works It removes spaces created by JSP tags. It will not remove spaces in body. trimDirectiveWhitespaces=”false” trimDirectiveWhitespaces=”true”;

Read More

by , on August 27th, 2017

Posted In: Server, Tomcat

Tomcat 9 – Why you should start using org.apache.tomcat.jdbc.pool

The JDBC Connection Pool org.apache.tomcat.jdbc.pool is a replacement or an alternative to the Apache Commons DBCP connection pool. So why do we need a new connection pool? Here are a few of the reasons: 1. Multi threaded. Support for highly concurrent environments and multi core/cpu systems. 2. Tomcat jdbc pool implements the ability retrieve a […]

Read More

by , on August 27th, 2017

  • Categories