is giving you NPE. You know that myHtml is null, because otherwise you would not have gotten out of the loop. So of course myHtml.toString() must give NPE.
debraj mallick wrote:
all i need is to print the entire string.
You mean the full HTML that you read in the loop? And you want to print the whole thing out after the loop exits? Then you have to build up a string or other data structure that holds the whole thing. Right now, your loop says:
Inside the loop you could use StringBuilder.append(), or, if you still need access to the individual lines, java.util.List.add().