Since you want to parse an HTML document and read its contents, there are two ways. First of them (the easy way) would be to use an HTML parser and then read the header values one by one. I have not heard of any in Java but with C# we had
HtmlAgilityPack[
^]; which in Java is somewhere to be like
JTidy[
^].
Second way is by using the Java APIs, which as per your statement you say,
Quote:
i tried to use the getHeaderFields() method but it didn't work
Luckily, for us, here is a thread on SO where the OP said the same thing that
getHeaderFields()
does not work for them, so they were provided with a solution for that, please see that thread. It takes more than just an extra code line or a rewrite, that is why I am attaching the link to the thread for you to read and go through,
java - Getting raw HTTP response headers - Stack Overflow[
^]