lundi 12 février 2018

How to replace a character in StringBuffer by another String in java

I am trying create a header from an excel file which has two headers in two different rows. I have to make them one header from the two rows, so the approach i am following is i am appending a @ to the first header and trying to replace it with the second header value. My excel file looks like this

Bank Positive Name of Local Approah Value Customer Civilian Remote

if(currentCell.getRowIndex()==4 ) {
                    if(cellValue.equals("Local Approah")) {
                        row.append(cellValue);
                        row.append("@");
                        break;
                    }else {
                        row.append(cellValue);
                        row.append("@");
                    }
                }if(currentCell.getRowIndex()==5) {
                    if(cellValue.equals("Remote")) {
                        row.append(cellValue);
                        break;
                    }else {
                        row.toString().replaceAll("@", cellValue);
                        row.append(cellValue);
                    }
                }

So in my output file header i am getting like

Bank@Positive@Name of@Local Approah@ Value Customer Civilian Remote

But my aim is to make

Bank Value Positive Customer Name of Civilian Approach Remote

Is it possible ? Can anybody help me ???

Aucun commentaire:

Enregistrer un commentaire