Reputation: 9043
How do one convert a String in java with 1 and 0s to corresponding ASCII value?
Lets say I have
String str = "01101110";
How do I convert it to be its corresponding 'n' so I can print n?
System.out.printl(str.toCorrespondingAscii());//output n
Upvotes: 0
Views: 667
Reputation: 3982
int value = Integer.parseInt("01101110", 2); //2 for binary
System.out.println(value); // To print ascii
char digit = (char) value;
System.out.println(digit); // To print n
Upvotes: 3