code: public static ResourceSnippet createResourceSnippet(Resource res, int startChar, int endChar, String charset) {
  
  	try {
  
  	    return createResourceSnippet(res.getInputStream(), startChar, endChar, charset);
  	}
  	catch (IOException ex) {
  
  	    return ResourceSnippet.Empty;
  	}
      }
docs: extract a ResourceSnippet from a Resource at the given char positions
  
  @param res - Resource from which to extract the snippet
  @param startChar - start position of the snippet
  @param endChar - end position of the snippet
  @param charset - use server's charset, default should be UTF-8
  @return