code: private String getString(int offset, int maxLength) {
          int index = offset;
          int lastIndex = index + maxLength;
          while (index < lastIndex && (buffer[index] != 0)) {
              index++;
          }
          return new String(buffer, offset, index - offset, StandardCharsets.ISO_8859_1);
      }
docs: Get a String from the buffer at the offset given. The method reads until
  it encounters a null value or reaches the maxLength given.