format - Replace string where it has .rpt -


i want read string in java has like

xyz.rpt abcde.img erhteds.doc aqwer.rpt 

and modify string has .rpt in it. if string has .rpt @ end need change .doc

output:  xyz.doc abcde.img erhteds.doc aqwer.doc 

the following code should replace last occurance of '.rpt' '.doc' if read line line

 stringbuilder b = new stringbuilder(yourstring);     b.replace(yourstring.lastindexof(".rpt"), yourstring.lastindexof(".rpt") + 1, ".doc" );     yourstring = b.tostring(); 

note throw exceptions if string doesn't contain '.rpt'


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -