so I\'m parsing html and I\'m trying to create a substring starting at a certain location and stop 941 characters after that. The way the .substring method in Java works is you
Since the second parameter is an index, not the length, you need to store the initial position, and add the length to it, like this:
String html = "This is a test string for example"; int pos = html.indexOf("test"); String res = html.substring(pos, pos+11);
Demo.