| Author |
BigInteger back to text
|
Stan Wilson
Greenhorn
Joined: Aug 19, 2004
Posts: 4
|
|
Hi all, I am doing some Encryption type studies and have encrypted then decrypted ok( I think). I am struggling to get what was initially a simple text file converted to byte then BigInteger, back to the same presentable text. Can someone advise a process from BigInteger to a file save state. What I have tried with all sorts of variations is from BigInteger, to byte [] via the toByteArray() method then String = new String(byte)..but still have all munched up characters when I view the file.. Any help appreciated. [ August 20, 2004: Message edited by: Stan Wilson ]
|
 |
Julian Kennedy
Ranch Hand
Joined: Aug 02, 2004
Posts: 823
|
|
Hi Stan, Since you have a text file it makes more sense to use the BigInteger(String) constructor. Try the following steps: Read in file using FileReader wrapped in BufferedReader (use getLine() method - assuming you have one BigInteger per line in the file) Create a new BigInteger with the String constructorPerform whatever operation you requireWrite the result back to the text file using FileWriter/BufferedWriter and BigInteger.toString() No mangling should occur. Hope that's useful. Jules
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
Moving this to the Intermediate forum...
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: BigInteger back to text
|
|
|