-1

I have to capture first paragraph characters and need to store in string.If the paragraph contains more than 300 characters we have to capture 300 only.

I wrote some code to do the same but it captures if the paragraph contains 300 or else it tries to captures from second paragraph. I have to capture first paragraph only.

String description = "Getting value from some paragraph as description";
if(StringUtils.isNotEmpty(description) && description  != null && description.length()>=300){
int maxValue = 300;
description  = description .substring(0, maxValue);
schema.add(description );
} else {
if(StringUtils.isNotEmpty(description) && description  != null && description.length()>=0){
schema.add(description);
}

Can any one suggest me how to capture the first paragraph with 300 characters.

Spartan
  • 3,213
  • 6
  • 26
  • 31
Mahesh C
  • 9
  • 3

1 Answers1

-1

Try this.

String description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
System.out.println(description.substring(0, 300));
jaylordibe
  • 111
  • 4