class Octal {

    private Octal() {
    }

    /**
     * Converts an array of bytes into a String where unprintable characters are represented as octal numbers.
     */
    public static String encode(byte[] data) {
        final StringBuilder sb = new StringBuilder(data.length);

        for (byte b: data) {
            if (b == 92) {
                sb.append("\\\\");
            } else if (b < 32 || b > 126) {
                // unprintable character
                sb.append('\\');
                sb.append((b >> 6) & 0x3);
                sb.append((b >> 3) & 0x7);
                sb.append(b & 0x7);
            } else {
                sb.append((char) b);
            }
        }
        return sb.toString();
    }

    public static byte[] decode(String octalData) {<FILL_FUNCTION_BODY>}

    /**
     * Checks the given character is a number in base 8.
     */
    private static int ensureOctalCharacter(char[] chars, int index) {
        final int o = Character.digit(chars[index], 8);
        if (o > 7 || o < 0) {
            throw new IllegalArgumentException(
                String.format(Locale.ENGLISH, "Illegal octal character %s at index %d", chars[index], index)
            );
        }
        return o;
    }

    private static void throwOnTruncatedOctalSequence(int index) {
        throw new IllegalArgumentException(
            String.format(Locale.ENGLISH, "Invalid escape sequence at index %d:" +
                                          " expected 1 or 3 more characters but the end of the string got reached", index)
        );
    }

}

        final byte[] decodedBytes = new byte[octalData.length()];
        final char[] encodedChars = octalData.toCharArray();
        int decIndex = 0;

        for (int encIndex = 0; encIndex < encodedChars.length; encIndex++) {
            final char c = encodedChars[encIndex];
            if (c == '\\') {
                if (encIndex + 1 >= encodedChars.length) {
                    throwOnTruncatedOctalSequence(encIndex);
                }
                if (encodedChars[encIndex + 1] == '\\') {
                    decodedBytes[decIndex++] = '\\';
                    encIndex++;
                    continue;
                }
                if (encIndex + 3 >= encodedChars.length) {
                    throwOnTruncatedOctalSequence(encIndex);
                }
                decodedBytes[decIndex++] = (byte) (64 * ensureOctalCharacter(encodedChars, encIndex + 1) +
                                                   8 * ensureOctalCharacter(encodedChars, encIndex + 2) +
                                                   ensureOctalCharacter(encodedChars, encIndex + 3));
                encIndex += 3;
            } else {
                decodedBytes[decIndex++] = (byte) c;
            }
        }
        if (decIndex == decodedBytes.length) {
            return decodedBytes;
        }
        return Arrays.copyOf(decodedBytes, decIndex);
    
<no_super_class>