Quantcast

overwriting an existing file with Groovy ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

overwriting an existing file with Groovy ?

Markus Jais-2
hello

I am using Groovy to generate the config file for
Cruise Control.

I have this code:

def configFile = new File(CC_CONFIG)
configFile.createNewFile()
configFile << "<cruisecontrol>\n\n"
.....


writing the file works. but when the file already
exists, the new content is appended. how can I
overwrite the existing file with the new content ?

called "createNewFile" didn't work. I couldn't find
anything in the docs.

best wishes

Markus





       
               
___________________________________________________________
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: overwriting an existing file with Groovy ?

Guillaume Laforge
Administrator
Try something like

def w = configFile.newWriter()
w << "..."

http://groovy.codehaus.org/groovy-jdk.html#meth88

On 7/16/07, Markus Jais <[hidden email]> wrote:

> hello
>
> I am using Groovy to generate the config file for
> Cruise Control.
>
> I have this code:
>
> def configFile = new File(CC_CONFIG)
> configFile.createNewFile()
> configFile << "<cruisecontrol>\n\n"
> .....
>
>
> writing the file works. but when the file already
> exists, the new content is appended. how can I
> overwrite the existing file with the new content ?
>
> called "createNewFile" didn't work. I couldn't find
> anything in the docs.
>
> best wishes
>
> Markus
>
>
>
>
>
>
>
> ___________________________________________________________
> Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: overwriting an existing file with Groovy ?

Markus Jais-2
thank you, Guillaume. exactly what I needed.

Markus


--- Guillaume Laforge <[hidden email]> schrieb:

> Try something like
>
> def w = configFile.newWriter()
> w << "..."
>
> http://groovy.codehaus.org/groovy-jdk.html#meth88
>
> On 7/16/07, Markus Jais <[hidden email]>
> wrote:
> > hello
> >
> > I am using Groovy to generate the config file for
> > Cruise Control.
> >
> > I have this code:
> >
> > def configFile = new File(CC_CONFIG)
> > configFile.createNewFile()
> > configFile << "<cruisecontrol>\n\n"
> > .....
> >
> >
> > writing the file works. but when the file already
> > exists, the new content is appended. how can I
> > overwrite the existing file with the new content ?
> >
> > called "createNewFile" didn't work. I couldn't
> find
> > anything in the docs.
> >
> > best wishes
> >
> > Markus
> >
> >
> >
> >
> >
> >
> >
> >
>
___________________________________________________________
> > Der frühe Vogel fängt den Wurm. Hier gelangen Sie
> zum neuen Yahoo! Mail: http://mail.yahoo.de
> >
> >
>
---------------------------------------------------------------------

> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
>
> --
> Guillaume Laforge
> Groovy Project Manager
> http://glaforge.free.fr/blog/groovy
>
>
---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Markus Jais
http://www.mjais.de




       
               
___________________________________________________________
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Loading...