0

i need to use java to generate and write/append (long)numbers to a text file and use those data for calculation later. can anyone give me a quick reference on what i should use?

i tried:
PrintWriter ---> no writeLong()
RandomAccessFile and BufferedWriter --> give me byte code

i have been googling around and got a bunch of stuff would give me "byte code" in the text (i need the regular text) ... and PrintWriter doesn't have writeLong() method.... Please help.

thanks

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by masijade
0

Simply write it as a String, and later use Long.parseLong or Long.valueOf to get the long value again.

However, if it is only to write and read longs I don't see why you don't use RandomAcessFile (without wrapping it in a BufferedWriter, it's not meant to be wrapped in anything) to read and write it directly.

0

Write the primitive data [long data in your case] using DataOutputStream and read the same if required using DataInputStream.

0

Simply write it as a String, and later use Long.parseLong or Long.valueOf to get the long value again.

However, if it is only to write and read longs I don't see why you don't use RandomAcessFile (without wrapping it in a BufferedWriter, it's not meant to be wrapped in anything) to read and write it directly.

i tried randomAccessFile with bufferedWriter... it gave me byte code to the text... i need to import that text doc to excel for some data process.. so..

0

i need to use java to generate and write/append (long)numbers to a text file and use those data for calculation later. can anyone give me a quick reference on what i should use?

thanks

You can create a connection stream and chain it to a a chaining stream.

FileWriter writeFile = new FileWriter(File, boolean append);
Buffered writer = new BufferedWriter(writeFile);

writer.write(here goes your long data);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.