You need to assign the file, open it, and reset to the beginning. You don't show any of that.
I don't know why it does not work (and the code below will not fix it), but
for(int i=0; i < line.length(); i++)
count++;
can be written more concise as
count += line.length();
Why are you using a Scanner ? A simple Reader would suffice. If you insist in using a Scanner, you must understand that it divides its input in fields separated by some pattern (a space by default), perhaps one can set an empty pattern so that the fields correspond with the characters (but again, that would be overkill, just use a Reader)
What delimiter are you setting for the scanner? You don't show it in your code, but you need to make it treat a line as a single token.
scanner.useDelimiter("\n");
Also, you say that the second code example worked perfectly. Did you print out the value of line to verify that it contained anything? It might have counted the lines properly, but if line didn't actually contain anything then that would help explain why it doesn't enter your for loop.
Have you already read everything from the Scanner before passing it to getcharCount()
?
I haven't worked with Scanner too much, but wouldn't
textFile.hasNextline();
make a little more sense than
textFile.hasNext();
Just a thought--I'm not sure if that would have any major effect on the execution