You *can't create* a file into the public folder, 'cuz is packaged, what you
*can do* is write it on the WebContent folder.

*Be aware of multiple calls at this process, because they may overwrite your
file, and you'll not get the real data.*

To do it, use PrintWriter or RandomAccessFile

but you need to address the location manually and this will be attached to
whatever operating system and web server you are using.

When you create any of those object and you put only the file name, then it
will be created inside the folder where the webserver started, in tomcat's
case is the bin folder, but in other web servers may have another name

so, you may wanna try something like this.

PrintWriter out = new PrintWriter("../webapps/applicationFolderName/file.xml",
> true);
>
> then use
>
> out.println("String goes here");
>
> or
>
> RandomAccessFile out = new RandomAccessFile ("../webapps/
> applicationFolderName/file.xml", "rw");
>
> then use
>
> out.println("String goes here");
>


Sometimes server does not allow war uncompression, in this case, it's not
possible to do it.

*doing testing is different, because the IDE setups another path for locate
the project, so when you make any change you dont have to redeploy, so you
may have some issues finding the right location.*
*
And don't forget to close the resources*

the best way to do it is,

PrintWriter out = null;
>
try{
>     //do the writing...
> }catch(Exception ex){
>     //take care of the error
> }finally{
>   if(out != null){
>      try{
>         out.close();
>      }catch(Exception ex){}
>   }
> }
>

Hope it helps,
_____________________
Ing. Gabriel Gutiérrez


On Mon, Apr 20, 2009 at 12:35 PM, Neo <[email protected]> wrote:

>
> Hi,
> I am trying to create a file using some server side code. The file
> gets created in the Project's root directory ?
> Is there a way to create a file inside the public directory of the
> application or atleast copy it to the public directory ?
> Once the file is created I want to read this file from my client side
> code. Right now I am not able to do so as the client side code has no
> access to resources outside the public directory :(
> Please help me out in this.
> If you know of any better approach please tell m
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to