I have a string of 0 and 1. I want to convert this string into another string by taking the 8 characters at a time and converting it to an Integer in binary and then casting this Integer to a character.
Code :
String s2="";
String s="10000111";
char nextChar;
for(int i = 0; i < s.length(); i += 8)
{
nextChar = (char)Integer.parseInt(s.substring(i, i+8), 2);
System.out.println(nextChar);
s2 += nextChar;
}
The code gives the right answer if I run it as a simple java file, but when I run it in a web application, it gives strange results. Why is this, and how can I get the web application to produce the same result?
In desktop application :
http://postimg.org/image/ww88p3ot5/
In web application :
(in browser)
135,
31,
120,x
27,
192,À
242,ò
146,
128,
255,ÿ
14,
11,
107,k
159,
(on output screen)