private static String cleanPart(String part) {
        final char[] in = part.toCharArray();
        final char[] out = new char[in.length];
        int outIndex = 0;

        for (final char c : in) {
            if (Character.isAlphabetic(c) || Character.isDigit(c) || c == '.' || c == '_' || c == '-') {
                out[outIndex++] = c;
            } else {
                out[outIndex++] = INVALID_CHAR_REPLACEMENT;
            }
        }

        if (outIndex > MAX_PART_LENGTH) {
            LOGGER.debug("File part exceeds max length: {}", part);
            outIndex = MAX_PART_LENGTH - 1;
            out[outIndex++] = TRUNCATED_VALUE;
        }

        return new String(out, 0, outIndex);
    }
Clean part of a path so that it doesn't contain invalid characters and is less than the maximum length of a part.

@param part The part of the path to clean.
@return A cleaned path part.
stroom-data/stroom-data-zip/src/main/java/stroom/data/zip/StroomFileNameUtil.java