I have a very biiiiiig string
"aijsdif_213 uweobasjdbfajb
ajksdbfaj-sd_bh kjsham
aisj_drieuku*qger ijwel,34jn
iu32iu4h8heuih+_8u5jns.. iuw&^ijk
.
.
.
.iuwh3iuw"
I want to split it for every ~1400approx. characters including the line breaks.
I used something like this,
Splitter.fixedLength(maxLength).split(biiiigString);
EDIT: Splitter is from 'com.google.common.base.Splitter'
But, since the splitting it for exactly 1400 characters would yield splitting at the middle of the lines and would make the split string meaningless to read. I want to match till the end of the line (i.e., till the next line break) where the 1400 characters match and then split the string.
I tried the below to check my luck,
Splitter.onPattern("(.|\\r\\n){1400}[^\\n]*\\n").split(biiiigString)
But, this cannot split as this cannot ignore the characters till last line break.
I googled few many times but could not get any. Though, i saw a switch statement like \K would ignore all the matched regexPatter before it, this is not supported by java.
I need a solution in java to get this thing working.
start
and check if the character is a char. If so, find the space before that indexend
, and setend
as new index. Then substring from store the partial string. Repeat this process with a new starting index:start = end
until end of string.