Question: I am using `msbuild` script to deploy `ssrs` reports. Previously all reports used to be in one folder and I have written a `msbuild` script to deploy these reports to report server. Now we are maintaining reports at folder level such as `customer service, inventory` and `invoice` folders. 

How to deploy these individual folder to report server? In report server also we need folder level hierarchy.

Answer: 
In my opinion the following will be a better way.

`str = s.substring( i,i+k ).intern() ;`
Remove the `new String` part first and move the `String str` out of the loop. We somehow need to make sure that the string returned from `subString` is unique.
Using the `intern` makes Java reuse the same strings. A note for caution though. Using [intern](https://en.wikipedia.org/wiki/String_interning) will slow your code down.

It will save memory though.
This line 

```
String str = new String( s.substring( i,i+k ) );

```

causes memory leak. You should avoid instantiations inside loops.