3

I have an Integer value that is to long to be exported and displayed correctly in a CSV file.

the value is diaplyed like this:

1,13364E+12

instead of something like this:

08136677950770

I use BufferedWriter to write the file, and the code looks like this:

writer.write(data[0].toString());
writer.write(";");

I've tried like this:

writer.write("\'"+data[0].toString()+"\'");
writer.write(";");

but it displays this:

'08136677950770'

How can I display this value without the quotes?

08136677950770

3 Answers 3

2

I recommend you using the BigInteger, that works with the String representation.

To get its value use simple toString() method.

BigInteger bi = new BigInteger("1234567890"); 
String str = bi.toString();
Sign up to request clarification or add additional context in comments.

Comments

0

When you use microsoft excel or some application program to open the csv and it shows this way 1,13364E+12 . It doesn't mean the value has changed. It is excel that has formatted it the way it like. But the value is still the same.

You can use ordinary notepad to open it and see the actual value.

Again try changing

writer.write("\'"+data[0].toString()+"\'");

to

writer.write("\""+data[0].toString()+"\"");

OR to this if it doesn't work.

writer.write(data[0].toString()+"");

Comments

0

I've tried your solutions, but none of them worked.

I've found the solution that consist to add the simple Tab character (/t ASCII 9) at the end:

writer.write(data[0].toString()+"\t");

Comments

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.