Hi, I continue with the problem that I've posted on jena-dev @ yahoo. I change the code to close the stream out of the loop. This is the new code:
http://pastebin.com/GhQXe2tg The problem is that the generated files continue empty :-/ Thanks, Alejandro --- In [email protected], "jalo_rg" <alejandro.rod.gnz@...> wrote: > > Silly mistake! > > Thanks Dave! And sorry for posting here, I saw the deprecation just after send the email. > > Thanks! > > --- In [email protected], Dave Reynolds <dave.e.reynolds@> wrote: > > > > This list is deprecated, jena support has moved to Apache, see: > > http://jena.apache.org/help_and_support/index.html > > > > Your problem is that you are closing the output stream within the loop: > > > > while (sti.hasNext()) { > > Statement st = (Statement) sti.next(); > > for (Iterator<?> id = this.inferenceModel.getDerivation(st); id > > .hasNext();) { > > Derivation deriv = (Derivation) id.next(); > > deriv.printTrace(out, true); > > } > > ... > > out.flush(); > > out.close(); > > } > > > > So after the first iteration out is closed. If the first statement in > > the iterator happens to be a fact with no derivation then the first > > iteration doesn't generate any output and you end up with an empty file. > > > > Don't know why you aren't seeing IOExceptions. > > > > Dave > > > > On 16/07/12 16:56, Alejandro Rodríguez González wrote: > > > Hello to all, > > > > > > > > > I'm trying to see the derivation of some rules that I developing but the > > > derivation files that the code creates always are empty. > > > > > > I don't know if it is a problem with my code or maybe some bug. > > > > > > Here is the code: > > > > > > http://pastebin.com/P8EqXcXP > > > > > > The files are created correctly (explc1.txt - explc4.txt) but they have > > > no content. If I change the PrintWriter to print in screen (System.out) > > > and it seems to crash. The normal output (writing to file), returns the > > > following: > > > > > > http://pastebin.com/0u8TSATb > > > > > > If I change the PrintWriter to System.out it "cuts" (finish) and only > > > shows this (but without errors or exceptions): > > > > > > http://pastebin.com/PA5KFmmk > > > > > > I also have some doubts with my rules since they are not working as I > > > expected, but maybe I can fix it if I can access to the derivation (to > > > see what is going wrong). > > > > > > Thanks! > > > -- Dr. Alejandro Rodríguez González - PhD Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA Polytechnic University of Madrid http://www.alejandrorg.com Phone: +34 914524900 . Ext: 25550 *Once the game is over, the king and the pawn go back in the same box. - Italian proverb*
