If you're thinking about this from the perspective of storing data, also consider something like converting it to Base64 representation - it's fast, single parse and uses not too much extra space. Ideally you would only parse the String once and you wouldn't need to keep rebuilding your String array. This solution isn't as fast as it could be, but it should work. ![]() ![]() ( Note that \\ is escaped first as you don't want to re-escape it later.) replace("\'", "\\'") // <= not necessary Free Online Java String Escape Tool An escape sequence is a series of characters that represents a special character An escape sequence begins with a. * Escape a give String to make it safe to be printed or stored. In java, this can not be done by simply putting. Some of the other solutions here are simply wrong. This escape sequence is used when a string needs single quotations around it. Many of the solutions here suggest adding the Apache Commons Text and using StringEscapeUtils.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |