Here is my latest attempt:<br><br> List <Element> wordList;<br> ListIterator listIterator;<br> Element currentElement;<br> boolean isWanted = false;<br><br> Btn.addActionListener(new ActionListener() {
<br> public void actionPerformed(ActionEvent e) {<br> try {<br> isWrong = true;<br> if(isPrevious == false){<br> try {<br> BufferedWriter writer = new BufferedWriter (
<br> new OutputStreamWriter (<br> new FileOutputStream ("words.txt"),<br> "UTF-8"));<br> Format format =
Format.getPrettyFormat();<br> format.setEncoding("UTF-8");<br> XMLOutputter outputter = new XMLOutputter(format);<br> writer.write
("<word_list>");<br> writer.newLine();<br> writer.write("<title name ='words' />");<br> writer.newLine
();<br> if(isWrong == true){<br> while (listIterator.hasNext()){<br> outputter.output(currentElement, writer);<br>
writer.newLine();<br> }<br> }<br> else {<br> writer.write("</word_list>");<br>
writer.flush();<br> writer.close();<br> }<br> }<br> catch (IOException io) {}<br> advance();<br> }
<br><br> public void advance() {<br> isWanted= false;<br> //begin, get and print element<br> if(listIterator == null) {<br> listIterator = wordList.listIterator();<br> if(
listIterator.hasNext()) {<br> currentElement = (Element)listIterator.next();<br> txtWord.setText("<html>"+currentElement.getAttribute("word").getValue());<br>
}<br> }<br> //reached end, start over<br> else {<br> listIterator = wordList.listIterator();<br> currentElement = (Element)listIterator.next();
<br> }<br> }<br><br>This creates the words.txt file like it should but it locks the Btn and won't close the stream so I end up with a neverending document.<br><br>This is killing me.... but I don't want to give up because I've spent way too much time trying to figure it out!
<br><br><div><span class="gmail_quote">On 5/23/07, <b class="gmail_sendername">Grzegorz Kaczor</b> <<a href="mailto:grzegorz.kaczor@gmail.com">grzegorz.kaczor@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
please attach the whole loop code that sets currentElement too. I<br>think that the code you posted is too little to say something about<br>the reason of the problem.<br></blockquote></div><br>