You dont call a method with its complete signature like 'public static void main(String args)' and moreover you will have to ensure that you are giving the method all the parameters it requires.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Joined: May 26, 2010
In the end I called the method using main(null);
However the compiler is still not liking the calling the compiler is throwing out several of the same 2 erros below.
Apologies is there are any formatiing errors. The forum doesn't seem to like code pasted from notepad++
This is all the info i get from the compiler
The line 48 error relates to the call main(null); and the other error relates to calling the Find method.
I'll paste the code for my program below, its confusing me a little now.
See that :48 in the stack trace? That's the line where the exception comes from. When I try it it's the "br.close();" line. That means that br is null.
Since it isn't needed outside the loop I'd make br a local variable, only available within the loop:
That leaves a few other problems, one being a guaranteed StackOverflowError once one of your 4 booleans is true or arrayList.contains(resourceLine). From main, you create a new Find object, which will call main, which will create a new Find object, which will call main, which...
The buffered reader reads in all items within the resources folder from the readin path, so yep there are a bunch of files in there. also my original program before the adaption looks like the code in this example.
And this code has been tested and works below. so the location of the buffered reader is fine.
Initially i changed the search being and end variables to match the criteria that i wanted to extract from the resource folder. However the results brought back were both repetitive and in some cases irrelevant. Because of this i used the If statments to only store the data within the array if it does not contain any of the specified symbols OR if it already exists within the array.
Im a little confused now.
Joined: May 26, 2010
Also the error arises when the program is executed not when it compiles. I realise the error relates to both lines 48 and 117.
Line 48 is the main(null); line within the if check statement.
Line 117 relates to the calling of the Find method within the main method.
Which has nothing to do with the buffered reader. If you are getting path errors when running my program then thats probably either because you aren't referencing the same path.
It looks like its something to do with the way im calling the main and Find methods themselves in these two instances. I cant see how it referenced br.close.
The throw catch scenario is used to readin all items within the folder, if there are no items left the loop closes.
The line numbers you're quoting, and the code, don't match up. Too difficult to guess--either provide an offset, do the line number math for us, or do *something*. And there's no "main(null)" in the code you posted last, so I'm not sure what we're supposed to do with that information.
And if you're getting a stack trace, just post the stack trace, instead of little bits; if you're getting a compilation error, post the exact compilation error.
The main(null); are removed as the post has developed so has the code. If you look up in the post there are clear references as to where the errors (were) occuring. i.e. the main method reference to the find method. .. and the main(null)reference under the If check statement. I just didnt think it was necessary to keep pasting up references when I had done so many times before.
The code itself is now compiling and running. Thank you for the comments.
The only issue now, which i believe i've posted in a new thread. Is that altho it compiles and runs its still writing irrelevant data to the specified text file. Which is a bit weird.
Your post before this one, then, referred to code that no longer existed: re-read what you posted; it doesn't make sense if that code no longer exists.
Joined: May 26, 2010
I see what you mean. however in my original post lines 48 and 117 are referenced correctly. I just took out some of the comment lines in the laterposts to save time, that was the only reason.
I took out the references to the main method because i actually realised that they werent necessary, i mean if theyre in the loop and the instance is not what i want it does not need to go back to the main. It simply needs to iterate through the IF statement until the end of the loop and then read the next line.
Staring at code for too long lol.
I'll make sure that in future posts I post exactly with reference to compiler messages etc.