How to include a test string with \n, \r, \t, umlauts etc?
Um... just type it the way you want? You can use \n, \r and \t, umlauts stc. in Java String literals; if you're worried about the encoding of the source code file, you can use Unicode escape sequences, and you can produce them using the native2ascii tool that comes with the JDK.
How to set the encoding?
Once you have a Java String, it's too late to worry about encodings - they use UTF-16, and any encoding problems occur when translating between Strings and byte arrays (unlike C, Java keeps these concepts clearly separate)
Edit:
If your Strings are too big to be comfortably used in source code or you're really worried about the treatment of line breaks and white space, then keeping each String in a separate file is probably best; in that case, the encoding must be specified when reading the file (In the constructor of InputStreamReader
)