I am trying to trim leading whitespaces from the string and I do not know what is wrong with my approach, any suggestions would be appreciated ?
Code:
this.poNumber = poNumber.equals("") ? poNumber : poNumber.trim();
am reading poNumber from csv file as " IG078565 and IG083060 " and output also am getting same value with same whitespaces, not sure why ?
Updated
Adding complete method for better context:
public BillingDTO(String currency, String migrationId, String chargeId, String priceId, String poNumber, String otc,
String billingClassId, String laborOnly) {
super();
this.currency = currency.equals("") ? currency : currency.trim();
this.migrationId = migrationId.equals("") ? migrationId : migrationId.trim();
this.chargeId = chargeId.equals("") ? chargeId : chargeId.trim();
this.priceId = priceId.equals("") ? priceId : priceId.trim();
this.poNumber = poNumber.equals("") ? poNumber : poNumber.trim();
//poNumber.trim();
//System.out.println("poNumber:"+this.poNumber.trim());
//this.poNumber = poNumber.equals("") ? poNumber : poNumber.trim();
this.otc = otc.equals("") ? otc : otc.trim();
this.billingClassId = billingClassId.equals("") ? billingClassId : billingClassId.trim();
this.laborOnly = laborOnly.equals("") ? "N" : laborOnly;
}
Thanks.