...
| Code Block | ||
|---|---|---|
| ||
BigInteger x = new BigInteger ("530500452766");
String s = x.toString(); // valid character data
try {
byte [] byteArray = s.getBytes("UTF8");
String ns = new String(byteArray, "UTF8"); // ns prints as "530500452766"
BigInteger x1 = new BigInteger(ns); // construct the original BigInteger
} catch (UnsupportedEncodingException ex) {
// handle error
}
|
Do not try to convert the String object to a byte array to obtain the original BigInteger. Character encoded data may yield a byte array which, when converted to a BigInteger, results in a completely different value.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e8e87fb22425878c-d6251e0d-4f3c4004-903a90d2-f30068b988cc5d872918903c"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | class [String | http://java.sun.com/javase/6/docs/api/java/lang/String.html] | ]]></ac:plain-text-body></ac:structured-macro> |
...