Java has cool URL parser
import java.net.*;
import java.io.*;
public class ParseURL {
public static void main(String[] args) throws Exception {
URL aURL = new URL("http://example.com:80/docs/books/tutorial"
+ "/index.html?name=networking#DOWNLOADING");
System.out.println("path = " + aURL.getPath());
}
}
Here is the output displayed by the program:
path = /docs/books/tutorial/index.html
I would like to take only this part : docs/books/tutorial
(or /docs/books/tutorial/
) Guessing don`t use string split, I am looking for other better resolution for this task.
Thank you in advance