Karl Barnard

Greenhorn
+ Follow
since May 15, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Karl Barnard

Just got a little problem with a method i'm creating...



What the method is supposed to do is count the number of characters in the file whose name is supplied as the "name" parameter. The method returns the number of characters in the file or -1 if an IOException occurs.

The problem is that i get a compile error that says "cannot find symbol - method length()".

Is there something i wrote in the code which is why it can't find the length()?
14 years ago


This is the code, but is says "cannot find symbol - method length()".

Anyone know what i'm doing wrong?
14 years ago
Written up a code, just need to test it.
14 years ago

David Newton wrote:

Oh, it's not.


Perhaps you could write the method in such a way that it is.



No problem. I've sorted it out now David Newton.

Thank you very much and sorry for being such a pain in the ass!
14 years ago

David Newton wrote:Where are you defining "number"? Is it in a scope visible to the return statement?


Oh, it's not.

What other way can i get an int result instead of a null?

I'm stuck on this one, the code looks right, but i honestly can't see where i'm going wrong.
14 years ago
Okay sorry about that.

You said...

Where in your code do you do a mathematical operation? What value are you trying to calculate?



It's here

So the value i'm assuming is "number".

If I set the return as...

or

I get an error saying it can't find number.

Know what i'm doing wrong?
14 years ago

David Newton wrote:Going back and deleting your comments seems a bit odd, and make a lot of the thread nonsensical.



Hi David Newton.

I got the code working now, that was a added reason why i deleted (sorry if that was wrong).
14 years ago

Paul Clapham wrote:Karl, I would appreciate it if you could read this FAQ entry:

BeForthrightWhenCrossPostingToOtherSites

and act accordingly. Thanks in advance for your cooperation.



Okay sorry about that.
14 years ago
Thanks a lot guys, all your post have been noted.
14 years ago

Write a method called sizeFile() declared as follows:

public int sizeFile (String label) {
...
}

which counts the number of characters in the file whose name is supplied as the "label" parameter. This method should return the number of characters in the file, or -1 if an IOException occurs.



I'm not looking for someone to answer this for me, i'm just looking for hints, tips or examples of how i can go about this.
14 years ago

David Newton wrote:Did you import BufferedReader?


Yes

David Newton wrote:Is there a BufferedReader ctor that takes an InputStream?


I'm not sure, can you explain this a bit more?

David Newton wrote:Did you *not* have that compilation issue before?!


Yes, i did.
14 years ago