List<Chunk> chunk() {
            StringBuilder currentChunk = new StringBuilder();
            int currentLength = 0;
            while (index < text.length()) {
                int currentChar = text.codePointAt(index);
                currentChunk.appendCodePoint(currentChar);
                if (endOfChunk(++currentLength)) {
                    chunks.add(new Chunk(currentChunk.toString()));
                    currentChunk.setLength(0);
                    currentLength = 0;
                }
                index = nextIndex();
            }
            if (currentLength > 0)
                chunks.add(new Chunk(currentChunk.toString()));
            return chunks;
        }
Computer with the scope of chunking a single input text.
linguistics/src/main/java/ai/vespa/language/chunker/FixedLengthChunker.java