guava/src/com/google/common/base/Splitter.java
public static Splitter fixedLength(final int length) {
    checkArgument(length > 0, "The length may not be less than 1");

    return new Splitter(
        new Strategy() {
          @Override
          public SplittingIterator iterator(final Splitter splitter, CharSequence toSplit) {
            return new SplittingIterator(splitter, toSplit) {
              @Override
              public int separatorStart(int start) {
                int nextChunkStart = start + length;
                return (nextChunkStart < toSplit.length() ? nextChunkStart : -1);
              }

              @Override
              public int separatorEnd(int separatorPosition) {
                return separatorPosition;
              }
            };
          }
        });
  }
public static Splitter fixedLength(final int length) {
    checkArgument(length > 0, "The length may not be less than 1");

    return new Splitter(
        new Strategy() {
          @Override
          public SplittingIterator iterator(final Splitter splitter, CharSequence toSplit) {
            return new SplittingIterator(splitter, toSplit) {
              @Override
              public int separatorStart(int start) {
                int nextChunkStart = start + length;
                return (nextChunkStart < toSplit.length() ? nextChunkStart : -1);
              }

              @Override
              public int separatorEnd(int separatorPosition) {
                return separatorPosition;
              }
            };
          }
        });
  }
Returns a splitter that divides strings into pieces of the given length. For example, {@code
Splitter.fixedLength(2).split("abcde")} returns an iterable containing {@code ["ab", "cd",
"e"]}. The last piece can be smaller than {@code length} but will never be empty.

<p><b>Note:</b> if {@link #fixedLength} is used in conjunction with {@link #limit}, the final
split piece <i>may be longer than the specified fixed length</i>. This is because the splitter
will <i>stop splitting when the limit is reached</i>, and just return the final piece as-is.

<p><b>Exception:</b> for consistency with separator-based splitters, {@code split("")} does not
yield an empty iterable, but an iterable containing {@code ""}. This is the only case in which
{@code Iterables.size(split(input))} does not equal {@code IntMath.divide(input.length(),
length, CEILING)}. To avoid this behavior, use {@code omitEmptyStrings}.

@param length the desired length of pieces after splitting, a positive integer
@return a splitter, with default settings, that can split into fixed sized pieces
@throws IllegalArgumentException if {@code length} is zero or negative