I am working with files (reading, writing and copying) in my Java application, java.io.File and commons-io were perfect for this kind of tasks.
Right now, I can link to HTML in this way:
Z:\an absolute\path\to\a\file.html
But, I need to provide support for anchors too:
Z:\an absolute\path\to\a\file.html#anchor
keeping the system-independence obtained by using java.io.File. So, I will need to extract the path and the anchor, I wonder whether it will be as easy as searching for a sharp occurrence.
java.io.Fileincludes a constructor that accepts a URI, which can represent all kinds of resources, included URLs and local files (see the rfc). URI’s also meets your requirements of supporting anchors, and extracting path information (throughinstance.getPath()).