I think you need to do:
editedFile = editedFile.replaceAll(firstLineString, "Work you silly
code");
The replaceAll method returns a String, which I assume is the changed
string.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#replaceAll
(java.lang.String,%20java.lang.String)
Alex
> -----Original Message-----
> From: plug-discuss-admin@lists.plug.phoenix.az.us
[mailto:plug-discuss-
> admin@lists.plug.phoenix.az.us] On Behalf Of Ben Coffman
> Sent: Monday, May 03, 2004 2:26 PM
> To: ryan@the-calders.com
> Cc: plug-discuss@lists.plug.phoenix.az.us
> Subject: Re: Java
>
> I am trying to use the replaceAll() method, but I cannot get it to
work.
> i'm trying to pass in a variable and I want it to replace everything
that
> is
> in that variable?
>
> firstLineString is of type string also.
>
> editedFile.replaceAll(firstLineString, "Work you silly code");
>
> Thanks,
>
> Ben
>
>
>
> Ben Coffman said:
>
> > I have a file I want to locate a word within the file and then
erase
> that
> > word without erasing the rest of the file.
>
> Read your file into a StringBuffer and call replaceAll() on the
buffer's
> contents with an empty replacement to wipe all occurrances of your
word.
> Then, write over your old file with the new String.
>
> Ryan Calder
> ryan@the-calders.com
>
> _________________________________________________________________
> Express yourself with the new version of MSN Messenger! Download today
-
> it's FREE! http://messenger.msn.com/go/onm00200471ave/direct/01/
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss