private void escape(Writer writer, String s) throws IOException {
        if (s == null) { return; }
        for (int i = 0, len = s.length(); i < len; i++) {
            char c = s.charAt(i);
            switch (c) {
            case '<':
                writer.write("&lt;");
                break;
            case '>':
                writer.write("&gt;");
                break;
            case '&':
                writer.write("&amp;");
                break;
            case '\r':
                writer.write("&#xD;");
                break;
            default:
                writer.write(c);
                break;
            }
        }
    }
The line separator to use (default is the based on the current system settings).
jme3-plugins/src/xml/java/com/jme3/export/xml/DOMSerializer.java