Reputation: 1161
I need to convert a string like "2015114734WO|https://example.com/myresearch/2015114734WO/work/data:/1"
to a long data type and vice versa. It should get converted to a long data type and when algorithm is re-applied, I need to get back "2015114734WO|https://example.com/myresearch/2015114734WO/work/data:/1"
.
Please let me know if there is any ready algorithm I can use?
Thanks.
Upvotes: 0
Views: 46
Reputation: 4296
Assuming you mean 'long' as in integral, you could use BigInteger
. e.g.
BigInteger bi = new BigInteger(s.getBytes("UTF-8"));
'Decode'
byte[] b = bi.toByteArray();
for(int i = 0;i < b.length;i++) {
System.out.print((char)b[i]);
}
Upvotes: 2