Originally posted by: notfred
Originally posted by: Ameesh
make checkSignature() a static function
and you should be fine.
If I do that it just complains about the FileInputStream. Basically, it complains as soon as I try and access anything that's not static. And main is required to be static. So, how do I do this without making everything in the whole program static? there's got to be some way to break out of this chain of static statements.
Why do you want to "get out of this chain of static statements?"
You can very easily, like this:
ReadPng myReadPng = new ReadPng();
myReadPng.startRead(...);
but why do you want to?
just make startRead and checkSignature static then you can call ReadPng.startRead() the way you are now.
You don't have any real need to have more than one copy of the checkSignature and startRead methods do you?
You only need one copy, they are what I would call "Utility" methods.
Static is exactly what you want a utility to read.
If you wanted to create a new copy of startRead and checkSignature to go with every PNG file you have, then you leave the methods non-static, but you have to instantiate ReadPng.
The way you have your code structured right now there is no good reason to do that.
I don't see why you want to not use static methods. But it's easy to do if you really want to, just with a new. Without an instantiation (call to new) you can never move from static to non-static.