why is toString() returning a "/" to my String path? [closed]
I have a toString() method that is returning a "/" at the beginning of the String, which is a filepath. this is seriously screwing up my program because it's not able to read the resource with that "/" in front:
public String toString() {
    return this.value;
  }
Any help would be greatly appreciated,
Edit:
Here's the c开发者_如何学运维onstant:
DELEGATE_JNDI_NAME("java:/comp/env/jndi/delegates"),
I'm guessing you're trying to pass the "java:/comp/emv/jndi/delegates" as an argument to your toString() method. I don't see any leading /'s, but if you do get one, use this method to remove it...
String removeSlash(String file) {
     char[] letters = file.toCharArray();
     if (file.charAt(0) == '/'){ //first character is '/'
         return file.substring(1);
     } else {
         return file;
     }
}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论