I'm trying to use the StringEscapeUtils.escapeXML() function from org.apache.commons.lang...
There are two versions of that function, one which expects (Writer, String) and one which just expects (String)....
http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeXml(java.lang.String)
I'm trying to use the version that just expects the String parameter without the Writer, but Java is complaining that I've not given it a Writer.
How do I use this in my program so that I don't need a Writer?
String escXml = StringEscapeUtils.escapeXml(attr.get());
xml = xml.concat("<"+attr.getID()+">"+escXml+"</"+attr.getID()+">");
I've also tried just doing it inline in the string itself.
xml = xml.concat("<"+attr.getID()+">"+StringEscapeUtils.escapeXml(attr.get())+"</"+attr.getID()+">");
Both of these attempts have given me the error about it expecting the Writer though. Can anyone help me with this?
Thanks, Matt
The error message is telling you that you are passing an Object into the method, not a String.
If you are sure that the Object is a String, then you'll need to cast it to a String first.
If this doesn't work, please post the actual code that is giving you trouble.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With