I'm having some problems with encoding of my outputs. This is one of the cases:
"<" + this.strName + ">" + strData + "</" + this.strName + ">"
return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(returnFullTagData(strData).getBytes())).getDocumentElement();
On Netbean's debug is working correctly but when I run the Build version it throws Invalid byte 2 of a 3-byte UTF-8 sequence.
I Solved that problem with:
new String( ("<" + this.strName + ">" + strData + "</" + this.strName + ">").getBytes(), "UTF-8");
BUT I need to change this to work always like the first choise... why?, because this:
When i try to save the new XML file, it saves correctly on netbeans debug:
<kind schema="">Fonología</kind>
But, the build version has the same problem of encoding:
<kind schema="">Fonolog?a</kind>
I think both of this problems has a direct relation but i dont know how.
Of course, i tried to fix this changing the encode of the input data on my XML as the first case but i doesn't work
EDIT
Ok, now that i'm using some of your answers and I'm getting something very interesting.
First case, it was changed for:
strData = "<" + this.strName + ">" + strData2 + "</" + this.strName + ">";
return DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new InputSource(new StringReader(returnFullTagData(strData))))
.getDocumentElement();
And it's working nicely, no more ??? (And UnsupportedEncodingException it's not needed anymore, love it).
The second change it's the way it reads the XML base file
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
FileInputStream in = new FileInputStream(new File(strBase));
doc = dBuilder.parse(in, "UTF-8");
But now i have another problem:
<li>ArtÃculo Definido</li>
instead of
<li>Artículo Definido</li>
And it's kinda tricky because i'm using two types of nodes in this document and the "String Based" nodes are print correctly, but the "file based" nodes have that problem...
The libraries i'm using are POI, Guava, XMLBeans included with POI and dom4j
PD: Again, it only happens when it's the build version... why it happens?, I'm really tired to try debug and it's basically useless