When I split a String:
"EMP ID||EMP NAME||DESIGNATION"
I get each letter split:
[, E, M, P, , I, D, |, |, E, M, P, , N, A, M, E, |, |, D, E, S, I, G, N, A, T, I, O, N]
My code is
String strHeader="EMP ID||EMP NAME||DESIGNATION";
String[] arrStrColumnsInRow=strHeader.split("||");
How can I get it splitted like:
[EMP ID,EMP NAME,DESIGNATION]
Use
String[] arrStrColumnsInRow=strHeader.split("\\|\\|");
This is because the parameter of split
is a regular expression, where |
is a logical operator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With