Thanks for that, I thought that i was going to have to create another method to deal with it. Glad it wasn't.
My sisters rli not well, she didnt break anything but the docs did some tests on here and have noticed that shes got alot of bacteria in her bloody and some muscles damaged. Her bacteria count is supposed to be 8 and is sitting on average at around 113. She can barely walk so something is really wrong.
Hopefully after the scans etc come back they'll be able to sort things.
Thinking about something else entirely, is it easy to save the output from the program into a new file?
Hope your weekend was better at least the suns out today and we have some nice white clouds, its been horrible the last couple of days.
the examples im finding aren't that great, I've found an example that implements a try/catch method like in my program would i not use something along the lines of the example below, or is a method a more straight forward way?
So far I've just imported the necessary librarys and created a method, the other examples i found from the sun site weren't that helpful.
Your examples copies the content of one file into another file.
If that is what you want to do the example is right.
But if you want to put the elements of the ArrayList that you calculated in the previous steps in a file, just iterate through your ArrayList instead of through the lines of a BufferedReader, which, in that case, you could even delete.
you miss the import statement for PrintWriter
Whe you added it, call the method writeResults passing to it the ArrayList arrayList and a filename you chose to write to.
For example you could call that method at line 45 after the call to sortAndPrint method.
If you still have troubles, post the stack trace printed at runtime or the compile time error.
it's easy to see. Look at the signature of the method and how you called it.
Anyway pay attention on what you do, you are not thinking about the problem, you are following instructions mechanically.
I told you that you must pass the filename to the writeResult method. Why don't you do it? Where do you expect the arraylist is written?
I hope you had a nice weekend, although today seems to be a fight against the rain by the looks of it
Looking at the signature of the method, its called writeResults, which is what i've called, reading in the parameters of the filename and arraylist.
The way my mind was working was that I thought i would like to call in the arrayList to return and capture it and also the filename.
At first i simply used the "filename" as the parameter called but this also returned an error.
I realise this type of method is a private method, the same as the sortAndPrint which is called.
There's no variable called "filename"--that's why it can't find it. You need to *provide* a filename, either in an immediate string, or in a variable.
And you can't just post a hundred lines of code and say "look at the line where writeResults is called". Well, you *can*, but it'd be much easier if you just posted the exact error message, and the line of code that it happens on. Why make it difficult for people to help you?
The error is called at line 50 which simply states that it cannot find the variable name filename.
filename is a parameter of the method I am calling, aswel as arrayList. I simply left it the string name as filename for testing purposes.
You may have a fundamental misunderstanding about how Java methods work.
The filename you show *there*, in the method definition, defines the parameter *within the method*. Not outside of it. If you *call* the method you must provide an argument--an actual value. The value may be immediate ("foo.txt") or a variable within the *current* scope. Simply using a variable called "filename" doesn't magically create one in the *current* scope.
I simply thought that by using the parameter filename that it would generate a file of that such name.
So by using "filename.txt" within the call a new text file should be create?
Does this file also store within the same local directory as the program itself or is there a standard route folder like C:/programfiles/java that its stored in.
The reason that I ask is that I have tried this solution and although it compiles with no errors I cannot find the text file. No error message has come up informing me of the programs failure to write.
Lol of course the referenced route folder is the only place i looked, initially i thought that the file would have been created locally to the java program that references it, however when a file was not created i took the previously mentioned approach. Unfortunately the file is still no where to be seen