vendredi 8 mai 2015

How to save file programatically in WEB-INF resources in java?

The environment is MAVEN-based WILDFLY container!

Okay.. I can retrieve the URI of file as

Foo.class.getClassLoader().getResource("/images/nir.png");

But, how can I programatically add a file on that folder?

I did something like this:

Foo.class.getClassLoader().getResource("/text/");
OutputStream stream = new FileOutputStream(newjava.io.File(loader.getFile()+"1.txt"));
//add something on 1.txt, save it on web-inf folder!!

and from web, if i had to connect to this, i am not able to do so. WHY?

like..to access to server

http://server/text/1.txt

Why doesn't it work this way??

Aucun commentaire:

Enregistrer un commentaire