String outof bound range-1
HI,
I am trying to generate this following code but I am getting following errors. My idea was to return the token as arralist but I do not know why I am getting this kind of errors.Could you please give me some suggestion or help on this problem.
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1932)
at java.lang.String.substring(String.java:1905)
at TokenFile.getParentLabel(TokenFile.java:26)
at DEL.getTokenSenses(DEL.java:65)
at DEL.main(DEL.java:98)
public class TokenFile {
ArrayList<String> al=new ArrayList<String>();
public ArrayList<String> getParentLabel(String file) throws IndexOutOfBoundsException, IOException {
Label in=new Label();
Stack stack = new Stack();
String lastToken=null;
BufferedReader br = new BufferedReader(new FileReader(file)); // read text file by buffered reader
String line;
while ((line = br.readLine()) != null) {
String lastPath = line.substring( line.lastIndexOf("/"));
lastToken=lastPath.substring(1,lastPath.length());
al.add(lastToken);// add token to arraylist
System.out.println("ess="+al);
}
br.close();
return al;
}
}

