How to convert String to BigInteger representation and back in Java? -
let's suppose have string
, let's call foo
. string
can contain value, letters, numbers, special characters, utf-8
special characters, such á , on. instance, might real value:
"Érdekes szöveget írtam tegnap, 84 ember olvasta."
i have following 2 methods:
public biginteger tobiginteger(string foo) { //returns biginteger value can associated foo } public string frombiginteger(biginteger bar) { //returns string value can associated bar }
then:
string foo = "Érdekes szöveget írtam tegnap, 84 ember olvasta."; system.out.println(frombiginteger(tobiginteger(foo))); //output should be: "Érdekes szöveget írtam tegnap, 84 ember olvasta."
how can achieve this? thanks
the following code expect:
public biginteger tobiginteger(string foo) { return new biginteger(foo.getbytes()); } public string frombiginteger(biginteger bar) { return new string(bar.tobytearray()); }
however don't understand why need , interested of explanation.
Comments
Post a Comment