I need to parse String content as binary sequence and convert them to its UTF-8 equivalent String.
For example, UTF-8 binary equivalents of B, A and R are as follows:
B = 01000010 
A = 01000001 
R = 01010010
Now, I need to convert a string "010000100100000101010010" to string "BAR"
i.e. For above case input string with 24 characters are divided into three equal parts(8 character in each part) and translated to its UTF-8 equivalent as a String value.
Sample Code:
public static void main(String args[]) {
    String B = "01000010";
    String A = "01000001";
    String R = "01010010";
    String BAR = "010000100100000101010010";
    String utfEquiv = toUTF8(BAR);//expecting to get "BAR"
    System.out.println(utfEquiv);
}
private static String toUTF8(String str) {
    // TODO 
    return "";
}
What should be the implementation of method toUTF8(String str){}
 
    