StringIndexOutOfBoundsException

StringIndexOutOfBoundsException: String Index out of range: 13

I'm getting this error on the following code:

public URLReader(String URL){

String inputLine;

int k, inicioNome, tamURL = URL.length();

System.out.println(tamURL);// <- Displays the right value

System.out.println(URL);// <- Displays the right value

System.out.println(URL.charAt(1));// <- Displays the right value

System.out.println(URL.substring(1,12)); // <- Displays the right value

for(k=tamURL+1;k>0;k--)

if((URL.charAt(k) == '/') || (URL.charAt(k) == '\\'))//### <- Here is the problem....

inicioNome = k;

...

Do You know what is wrong...

[745 byte] By [Naberus666] at [2007-9-30 4:15:58]
# 1
for(k=tamURL+1;k>0;k--) {if((URL.charAt(k) == '/') ||So if URL is "hello" then tamURL is 5. The first time thru the loop, k will be 6 (tamURL+1). That's out of bounds. K should start at tamURL-1 and loop until k>-1.
atmguy at 2007-7-1 12:25:48 > top of Java-index,Administration Tools,Sun Connection...