Use the method “StringEscapeUtils.escapeJava” in Java lib “org.apache.commons.lang”
String x = "hello\nworld";
System.out.print(StringEscapeUtils.escapeJava(x));
More Related Contents:
- Want to generate unique key of 15 chars in java
- Why am I getting “Error: ‘else’ without ‘if'”? [duplicate]
- Why are static variables considered evil?
- Instantiating a generic class in Java [duplicate]
- Unable to list target platforms. Please make sure the android sdk path is correct
- Java Wait and Notify: IllegalMonitorStateException
- Parsing a string to date format in java defaults date to 1 and month to January
- How do I pass a primitive data type by reference?
- How do I add an image to a JButton
- Get the indices of an array after sorting?
- How to find out the currently logged-in user in Spring Boot?
- Access restriction: Is not accessible due to restriction on required library ..\jre\lib\rt.jar
- Java InputStream blocking read
- Array initialization differences java
- Setting java locale settings
- Can I turn off the HttpSession in web.xml?
- List
- Capture screen of GLSurfaceView to bitmap
- Listing all deployed rest endpoints (spring-boot, jersey)
- Difference between spring batch remote chunking and remote partitioning
- JFrame background image
- How can I create an array in Kotlin like in Java by just providing a size?
- What is the Metadata GC Threshold and how do I tune it?
- LibGDX: How to make tiled map tiles clickable?
- Hibernate using JPA (annotated Entities) and liquibase
- BroadcastReceiver not receiving download complete action
- What makes the execution order of threads unpredictable?
- java.lang.UnsatisfiedLinkError: no sqljdbc_auth in java.library.path
- What is the relation between ContentPane and JPanel?
- Can we load multiple Certificates & Keys in a Key Store?