code: public static String unescapeNewlines(String str) {
      boolean hadSlash = false;
      final int len = str.length();
      StringWriter out = new StringWriter(len);
      for (int i = 0; i < len; i++) {
        char c = str.charAt(i);
        if (hadSlash) {
          switch (c) {
            case 'n':
              out.write('\n');
              break;
            case '\\':
              out.write('\\');
              break;
            default:
              out.write(c);
          }
          hadSlash = false;
        } else {
          if (c == '\\')
            hadSlash = true;
          else
            out.write(c);
        }
      }
      return out.toString();
    }
docs: Inverse function to {@see escapeNewlines}
  @param str escaped string
  @return unescaped