My code utilizes XMLwriter and XMLObjectOutputStream to process with string.
The key point is the string may contain character zero (\0). If I use string.replace("\0", "")
there is no error reported.
If do not use string.replace("\0", "")
, it will report "character zero is not allowed in output".
However, I need to keep the original string so can use it next to output into a txt file. In this case, how to deal with the string to keep the \0 and also work with XMLwriter?
The string looks like:
NULNULSTX &The story of Florida
(open in Notpad++ shows NUL, open in txt just show space in NUL)
Here is the error info:
ERROR (SelectorManager.run): java.lang.IllegalStateException: character zero is not allowed in output
at org.xmlpull.mxp1_serializer.MXSerializer.writeAttributeValue(MXSerializer.java:849)
at org.xmlpull.mxp1_serializer.MXSerializer.attribute(MXSerializer.java:624)
Also, if the string cannot escape from null terminate, can we find another way to replace string (e.g. char, array...) to output the original info?