Reputation: 1189
Hey guys have a very basic question in Files writing in java. I want to write a long value to a file using FileWriter.write() function but it gives error. Here is the code
accountNos[i] = bA[i].getAccountNo();
fw.write(accountNos[i]);
Error: change accountNos[i] to int.
But if I change it then it would mean a loss of information and I tried converting it String but it says it cannot convert primitive type long to string. I did: fw.write(accountNos[i].toString());
Please help guys...
Upvotes: 0
Views: 177
Reputation: 41281
Use Long.toString()
:
fw.write(Long.toString(accountNos[i]));
Edit: It looks like accountNos
is declared as int[]
. Change it to be declared as long[]
.
Upvotes: 2