Wednesday, November 6, 2013

Remove the commas remove the bracket in Java

In this program you will learn Remove the commas and bracket We are going to use replaceAll() or replace() method of String class in Java. The description of the code is given below for the usage of the method.

Description of the code:-

Here, you will get to know about the replaceAll() or replace() method through the following java program. In the program code given below, we have taken a String Or list.

String name=String.valueOf(loginCountBean1.getM_strEmployeeName());
hssfCell1.setCellValue(name);
// you can use below line of code for replace the commas.
 
hssfCell1.setCellValue(name.replaceAll("\'", "")); 

 Using List :-

String data = String.valueOf(cells.next());

HSSFCell hssfCell = hssfHeader.createCell(x);

hssfCell.setCellValue(data);

 // you can use below line of code for replace the bracket  from List.

hssfCell.setCellValue(data.replace("[", "").replaceAll("]", "")); 



Note :- I am use here Excel sheet to display the result from Mysql server.


Thank you to read and welcome to add your suggestion .
 

No comments:

Post a Comment