String[] parts = input.split(" "); StringBuilder sb = new StringBuilder(); for (String part : parts) { int val = Integer.parseInt(part, 2); String c = Character.toString(val); sb.append(c); } System.err.println(sb.toString());