Java tutorial
//package com.java2s; public class Main { public static String appendAdditionalZeroOrOne(String binaryNum) { StringBuffer sb = new StringBuffer(); int current = 0; while (current < binaryNum.length()) { if ((binaryNum.length() - current) > 7) { sb.append(0); } else { sb.append(1); } for (int i = current; i < (current + 7); i++) { sb.append(binaryNum.charAt(i)); } current += 7; } return sb.toString(); } }