From: putra l. <jul...@ya...> - 2004-05-24 10:13:16
|
Dear TM4j Users,I am a novice in using TM4J. I want to use Tm4j to store data extractedfrom Email Header. I adapt some methods in "SerialiseTopicMap" and "Tolog"provided in the example of TM4J.When I read emails from mail server,extract information, format them intoTopic Maps and then write it to disk (in XTM format), I was successfull.Unfortunately, I got problem when I try to read the file containing thatTopic Map for the next use, add some more topics and then write again themodified-Topic-Map into file (the message was"Exception caught: java.lang.NullPointerException").(SEE CODE BELOW)I checked, the problem was not caused by the nullity of variables in thiscode. I do not know what is wrong. Could some of you make suggestion?Thanks in advance. public void run() throws Exception { int updated = 0; PrintStream ps=null; String f ="c:/TM4J/examples/topicmaps/test.xtm"; try { tmps = new mailTM(); if(fileExist(f)) { System.out.print("Reading file "+f+"\n"); tmps.tm= tmps.readTopicMap(f); //THIS METHOD TAKEN FROM TM4J EXAMPLE//TO SEE NUMBER OF ORIGINAL TOPIC IN THE FILE System.out.print("\nFile "+f+ " LOADED with"+tmps.tm.getTopicCount()+" topics\n"); } else { tmps.createBaseTopic(tmps.tm); updated=1; } Mail ml; for(int i=arr.begin;i<=arr.end;i++) { updated =1; ml=arr.getEmail(); tmps.makeTopics(tmps.tm,ml); //TO ADD NEW TOPICS TO tmps.tm//TO SEE THAT NEW TOPICS SUCCESSFULLY ADDED System.out.print("There are "+tmps.tm.getTopicCount()+" topics\n"); } if(updated==1) { ps = new PrintStream(new FileOutputStream(f));//ERROR FOUND IN THIS STATEMENT BELOW, I CHECKED tmps.tm,ps WERE NOT NULLHERE tmps.writeTopicMap(tmps.tm, ps); } } catch(Exception ex) { System.out.println("Exception caught: " + ex.toString()); } }} --------------------------------- Do you Yahoo!? Yahoo! Domains - Claim yours for only $14.70/year |