I think I got it to work. I'm trying to modify an existing example class that gets the html information about a specified website. I did the following:
Instead of having:
while (in.hasNextLine()) { System.out.println(" " + in.nextLine()); }
I modified it to:
Scanner in = new Scanner(u.getInputStream());
int i = 6;
while (i > 0) { System.out.println(" " + in.nextLine()); i = i -1; }
As a general tip, if you know in advance how many times you want to do something, a for() loop is the preferred solution. there's no reason for it to my knowledge - it's just the idiom that's used.
but even if you did
you still might have a problem with small files...
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Gift giving made easy with the permaculture playing cards