download:Senior Architect of JAVA at Turing College

static public String decodeRubust(String str) {

    if (str == null || str.length() < 1)
        return null;
    int num = Integer.valueOf(str.charAt(0) + "");
    int step = (str.length() - 1) / num;
    int helpStep = step;
    String[] matrix = new String[num];
    System.out.println(str.length() - 1);

    int duo = (str.length() - 1) % num;

    for (int i = 0, j = 1; i < matrix.length; i++, j = j + helpStep) {
        if (i < duo)
            helpStep = step + 1;
        else
            helpStep = step;

        matrix[i] = str.substring(j, j + helpStep);
        System.out.println(matrix[i]);
    }
    // print(matrix);

    return makeSense(matrix);

}

private static String makeSense(String[] matrix) {

    StringBuffer sb = new StringBuffer();
    for (int j = 0; j < matrix[0].length(); j++) {
        for (int i = 0; i < matrix.length; i++) {
            if (matrix[i].length() - 1 >= j)
                sb.append(matrix[i].charAt(j));
        }
    }

    System.out.println(sb.toString());

    String tmp = new String();
    try {
        tmp = URLDecoder.decode(sb.toString(), "UTF-8");
        tmp = tmp.replaceAll("\\^", "0");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        tmp = null;
    }

    if (tmp.subSequence(0, 7).equals("http://") && tmp.substring(tmp.length()-6).equals("0-null"))
        return tmp;
    else
        return null;
}