Raw String Literals

Have you ever felt the pain of using string types to store SQL queries in Java, with multiple opening and closing, single and double quotes? To add to the misery, perhaps you have used newline escape sequences and concatenation operators. Similar discomfort applies to using string types with HTML, XML, or JSON code. If you dread all of these combinations like I do, fear no more. Raw string literals are here to save you from the pain.

With raw string literals, you can easily work with readable, multiline string values, without including special newline indicators. Since raw string literals don't interpret escape sequences, it is simple to include escape sequences as part of the string values. The related classes also include management of margins.

In this chapter, we'll cover the following topics:

  •  The advantages and difficulties of using escape sequences in string values
  •  New methods added to the String class
  •  Margin management
  •  Delimiters
  •  Examples of using raw strings with varied multiline text data
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.26.108