I suggest using StringBuilder. It is efficient and can suit your task exactly.
String originalString = ... ;
// The new length of the string is
int newLength = originalString.length() +(int) Math.ceil ( originalString.length() / 100.0 );
StringBuilder builder = new StringBuilder ( newLength );
I'll refer to each 100 character part of the string as a "chunk" so that its easy to see what's going on.
int chunkStart = 0;
while ( chunkStart < originalString.length() )
{
// We find the index of the end of the chunk.
int endOfThisChunk = Math.min ( chunkStart + 100, originalString.length() );
// and this chunk to builder
builder.append ( originalString.substring( chunkStart, endOfThisChunk ) );
// append the new line character
builder.append ( '\n' );
// set the next spot for chunkStart
chunkStart = endOfThisChunk;
}
return builder.toString();
Hope that helps! If you need more explanation please let me know!