Difference between url and uri bael 864 hariprasad (#1987)

* Commit URUURLJNDIFS added.

* URI URL REST commit.

* Revert "URI URL REST commit."

This reverts commit d9e26399be.

* Difference URI URL REST BAEL-864.

* Commit Difference URI URL REST #864, small changes.

* Difference URI URL REST project has been moved to spring-rest.

* BAEL-864. Deleted unused project and did one small change.
This commit is contained in:
hariprasad108
2017-06-04 21:39:21 +02:00
committed by maibin
parent 29e3437545
commit c17d19ff21
11 changed files with 291 additions and 4 deletions

View File

@@ -0,0 +1,43 @@
package com.baeldung.filesystem.jndi;
import java.io.File;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class LookupFSJNDI {
InitialContext ctx = null;
public LookupFSJNDI() throws NamingException {
super();
init();
}
private void init() throws NamingException {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put (Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
// URI to namespace (actual directory)
env.put(Context.PROVIDER_URL, "file:./src/test/resources");
ctx = new InitialContext(env);
}
public InitialContext getCtx() {
return ctx;
}
public File getFile(String fileName) {
File file;
try {
file = (File)getCtx().lookup(fileName);
} catch (NamingException e) {
file = null;
}
return file;
}
}