0

I'm writing a program where I need to write data to csv. However the string what I'm writing to csv has some commas. So when I'm writing to it I'm getting values in different fields, which I don't want Eg: my string will come like : 165328,1234582,21346 I'm getting output as each value in one field, but I want the string as it is in one field

        while((s=lnr.readLine())!=null)
        {
                     str=s.split(" ");
                     br.write(str[7]);
        }

Please add the required thing to get the desired output. Eg : the string I'm writing will look like this 165328,123482,123414...

2

1 Answer 1

4

Write the string which contains comma in double quotes and then write it into the csv file with File Writer or any writer you wish .

 value="\"" +value + "\"";
 fos.append(value);
Sign up to request clarification or add additional context in comments.

1 Comment

tried this alreday, its appending without commas, I'm getting output like..1523278123 without commas(concatenated two numbers, without comma)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.