Hi,

I ran about the same kind of problem some weeks ago! The solution was that I 
registered fristly some Reader to the factory and than I worked for me! Here is 
a bit of the code! Hope this helps:

readerFactory = new ReaderFactory();
                chemFormatList = new ArrayList<IChemFormatMatcher>();
                if(readerFactory.getFormats().size() < 1) {
                        
chemFormatList.add((IChemFormatMatcher)MDLFormat.getInstance());
                        
chemFormatList.add((IChemFormatMatcher)MDLV2000Format.getInstance());
                        
chemFormatList.add((IChemFormatMatcher)MDLV3000Format.getInstance());
                        
chemFormatList.add((IChemFormatMatcher)SDFFormat.getInstance());
                        
chemFormatList.add((IChemFormatMatcher)Mol2Format.getInstance());
                        
chemFormatList.add((IChemFormatMatcher)CMLFormat.getInstance());
                        for (Iterator iter = chemFormatList.iterator(); 
iter.hasNext();) {
                                IChemFormatMatcher format = 
(IChemFormatMatcher) iter.next();
                                readerFactory.registerFormat(format);
                        }
                }
bufferedReader = new BufferedReader(new java.io.FileReader(fileName));
IChemObjectReader reader = readerFactory.createReader(bufferedReader);

Anywhy there is still the question if this is a feature or a bug of the cdk 
that we firstly have to register that kind of readers before we want to use the 
readerfactory. I would expect that the readerfactory knows defaultly the 
readers supported by the cdk!

Cheers,

Thomas


> -----Ursprüngliche Nachricht-----
> Von: "sushil ronghe" <[EMAIL PROTECTED]>
> Gesendet: 11.04.07 13:29:12
> An: "Egon Willighagen" <[EMAIL PROTECTED]>
> CC: [email protected]
> Betreff: [Cdk-user] help


> 
> I got the svn copy and successfully build the source in netbeans.
> Now i am running cdk with org.openscience.cdk.applications.FingerPrinter as a 
> main class.
> 
> i have provided the argument as  "E:\Model\acetone.MOL" 
> 
> while running i got this error 
> 
> E:\Model\acetone.MOL: error=
> java.lang.NullPointerException
>         at 
> org.openscience.cdk.applications.FingerPrinter.main(FingerPrinter.java:76)
> 
> then i checked the fingerPrinter.main class to see from where the error is 
> coming
> 
> it is coming from the highlighted area.
> 
> Means the reader is null.
> 
>  IChemObjectReader reader = new ReaderFactory().createReader(new 
> FileReader(input));
> 
> why this is happening.
>  
> 
>  
> 
>  
> 
> try {
>                 File input = new File(ifilename);
> 
>                  if(input.exists()){
>                     System.out.println("File  is Alive");
>                 }
>                 if (!input.isDirectory()) {
> 
>                     IChemObjectReader reader = new 
> ReaderFactory().createReader(new FileReader(input)); 
>                     if (reader.accepts(Molecule.class)) {
>                         ChemFile content = 
> (ChemFile)reader.read((ChemObject)new ChemFile());
> 
>                         List containersList = 
> ChemFileManipulator.getAllAtomContainers(content);
>                         if (containersList.size() > 0) {
>                             for (int j = 0; j < containersList.size
> (); j++) {
>                                 String print = 
> fingerprinter.getFingerprint((IAtomContainer)containersList.get(j)).toString();
>                                 System.out.println(ifilename + " ("+ j +"): 
> fingerprint=" + print);
> 
>                             } 
>                         }
>                     }
>                 }
>             } catch (Exception exception) {}
> 
>  
> 
> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> 
> strange,
> 
> then i changed the code to
> 
> Reader rr = new BufferedReader(new FileReader(input));
> IChemObjectReader reader = new ReaderFactory().createReader(rr);
> 
>  
> 
> but all the way the reader is coming empty.I have checked the existance of 
> file it is present.
> 
> the same code is running well with the other jars.
> 
>  
> 
> what could be the error and how can i solve it.
> 
>  
> 
> please help..
> 
>  
> 
> 
> 
> -- 
> ********************************
> sushil ronghe
> Center of Pharmacoinformatics
> India
> ********************************* 
> 
> -----------------------------------------------------------------
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> 
> -----------------------------------------------------------------
> _______________________________________________
> Cdk-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cdk-user
> 



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to