Login  Register

Re: string[] modification

Posted by Boizeau marielaure on Jan 30, 2008; 4:02pm
URL: http://imagej.273.s1.nabble.com/string-modification-tp3697362p3697364.html

Thank you for all your answer,
That work fine.

Code :
String[]  newname=listTIF;
newname[i]= "saignee-" + listTIF[i].substring(0,9)+".tif";
String pathsave =dir+"/imagesretraitees/"+newname[i];
IJ.saveAs("Tiff", pathsave);

Marie


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Johannes Schindelin
Sent: Wednesday, January 30, 2008 1:23 PM
To: [hidden email]
Subject: Re: string[] modification

Hi,

On Wed, 30 Jan 2008, Marie-Laure Boizeau wrote:

> I would like to selecte a part of a string to remove one part and add
> an other. (to save an image with the same raw of name) I have a list
> of string[] For each string[i] i would like to select the four first
> char and add for example "Modified" at the end of the string.

Instances of the String are immutable.  You have to construct new
instances, but that is pretty easy:

        string[i] = string[i].substr(4) + " Modified";

Hth,
Dscho