- Collections
- Thread
- File handling
- Exception Handling
- Lambda
- Streams
- Filter
- Lambda
- Map
- Servlet
- jsp
- hibernate
- one to one
- one to many
- Spring
- Spring mvc
- Spring Boot
- Spring rest
- Spring Jpa Integration
- CRUD Opeartion
- Mongo Repositry
- JPA operation
- Spring cloud
- Spring Security
- Security
- Jwt
- Zull level Security(Jwt, Spring Security)
- Caching (Redis)
- Testing Mockito, Junit, Cucumber framework
- Messaging (Active MQ, Rabbit MQ)
- Cucumber Spring test
- TypeScript
- Compoment
- Service
- Routing.....
- Rest
- java Memory management
import org.apache.commons.text.StringEscapeUtils;
public class HtmlEncoderExample { public static void main(String[] args) { // Your HTML string with a mix of encoded and non-encoded characters String htmlString = "This is a "quoted" string with £ and © entities.";
// Encode characters that are not already HTML entities
String encodedString = encodeNonHtmlEntities(htmlString);
// Print the encoded string
System.out.println("Encoded HTML: " + encodedString);
}
private static String encodeNonHtmlEntities(String input) {
// Encode characters that are not already HTML entities
String escapedString = StringEscapeUtils.escapeHtml4(input);
// Revert already encoded characters back to their original form
escapedString = escapedString.replaceAll("&(#[0-9]+|[a-zA-Z]+);", "&$1;");
return escapedString;
}
}