I am trying to print a really long character String using StringBuilder in Java. For ex. this code i'm using:-
repeat1=new StringBuilder();
for(j=0;j<long_string;j++)
repeat1.append('5');
System.out.print(repeat1);
The number of characters I am trying to print is more than (long_string=)80,000 or so. But the output gives a Runtime Error and the value that gets printed is Truncated after printing 65536 characters which I assume is the max +ve range of Characters in Java . Output is something like that :-
555555555555555555555555555555 ................................ ................................ ................................ ................................ 555555555555555555555555{-truncated-}
I don't know what I am doing wrong that it is not printing all the characters!!
You can create and print much larger Strings in Java.
To me it looks like your console/shell/terminal truncates the extremely long line.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.