JNDI Cast

Hello,

I'm learning JNDI with com.sun.jndi.fscontext.RefFSContextFactory.

I've got a problem. I try to list a directory and I get Objects. But I can't cast them into an instance of File.

I do this :

_p = new java.util.Properties();

_p.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");

_p.setProperty(Context.PROVIDER_URL,"file:///JAVA");

_ic = new InitialContext(_p);

NamingEnumeration ne = _ic.listBindings("serialisation");

while(ne.hasMore()) {

Object o = ne.next();

File f = (File) o;

System.out.println("Named object and its class in the context, " + o.toString());

}

But I got a CastException. Is this possible to get an instance of File from an Object ?

Thanks in advance !!

[822 byte] By [_anagram_] at [2007-9-30 18:24:05]
# 1
each one of those objects is a Binding class (javax.naming)you can then use getObject() from that Binding, try casting that to a File.hthm
yorkroad at 2007-7-6 19:34:24 > top of Java-index,Administration Tools,Sun Connection...
# 2
Thank you very much yorkroad ! It was the solution !!I have a last question : how can I know if a Binding contains a File. I'd like to be sure before casting the Binding if it's a File. Thanks a lot !!
_anagram_ at 2007-7-6 19:34:24 > top of Java-index,Administration Tools,Sun Connection...
# 3
... getClassName() always returns javax.naming.Binding.I
_anagram_ at 2007-7-6 19:34:24 > top of Java-index,Administration Tools,Sun Connection...