Hi,

On Sun, May 4, 2008 at 6:24 AM, demigodntu <[EMAIL PROTECTED]> wrote:
>  part of my code looks like:
>
>        try {
>            FileReader fr = new FileReader("***.xyz");

Make sure that ***.xyz is a single file, not a filter... you'll have
to do looping over a set of files differently.

>            XYZReader xyzreader = new XYZReader(fr);
>            ichemobject2 = xyzreader.read(ichemobject);
>        }
>        catch (Exception e){
>           System.out.print("Exception");
>        }

What IChemObject are you passing to the read() method?

You can use accepts() to test if a certain IChemObject is supported, e.g.:

xyzreader.accepts(Molecule.class);

>From 
>http://cdk.svn.sourceforge.net/viewvc/cdk/cdk/trunk/src/main/org/openscience/cdk/io/XYZReader.java?revision=10370&view=markup
you can see that only IChemFile is supported, so you would do:

FileReader fr = new FileReader("someFile.xyz");
XYZReader xyzreader = new XYZReader(fr);
IChemFile chemFile = xyzreader.read(new ChemFile());

>  There is always an exception.

What's the exception you get?

>  I'm wondering what kind of ichemobject shall I use as the parameter and
>  where does it come from.

The interfaces are defined in org.openscience.cdk.interfaces, and
there are three implementations, in org.openscience.cdk,
org.openscience.cdk.debug and org.openscience.cdk.nonotify.

>  Actually I don't quite understand why the input parameter in
>  xyzreader.read(ichemobject) was needed.

For user convenience... the alternative would be to always return a
IChemFile. But many file formats really contains a IMolecule, and is
thus added as shortcut...

The unit tests Rajarshi mentions, can be found at:

http://cdk.svn.sourceforge.net/viewvc/cdk/cdk/trunk/src/test/org/openscience/cdk/io/XYZReaderTest.java?revision=10775&view=markup

Egon

-- 
----
http://chem-bla-ics.blogspot.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to