Hi Guys Im New to Java, This is actually the second phase of my first program. I'll explain my issue first. I need to read in the contents of a resource folder into my program. Currently it only reads in one file.
Can anyone help, for example my code below is designed to extract the data between two strings and return that data as another string.
For each occurance of said string it is captured and stored within an array, the array is then sorted and its contents are then printed out in a new document.
So basically I now need to test my program against several files rather than just the one.
Can someone please help. thank you for your time, code will follow.
Hi akhter, im not sure to implement this in my program sorry.
As i mentioned in my post, this is actually an editation made to my first program a few weeks back, i havn't been learning java for very long at all so this is all new to me.
With your suggested code i removed the buffered reader and filereader references from my code, replacing them with your new directory code and had many stack trace errors.
This may sound cheeky but is there any chance you could copy your code into mine as this will give me the best way to reference folders accuractely if I ever need to again in the future.
I plan on documenting the method for my own references.
that's because now there is no Find() constructor ... the constructor signature has now changed to "public Find(String fileName, String begin, String end,String whereToWrite)" ... so you need to pass in the directory name(eg "C:/myDir"), beginning string (eg "<@dynamichtml" ), end string(eg "@>>), targer file name (eg "C:\\Documents and Settings\\Kieren McDonald\\Desktop\\Nick\\Java\\Test\\filetest.txt")...
The code will read all the files present in the folder myDir...
Another thing i would suggest is keep all this code in a method and call it instead of putting it in the constructor...
Ok you fixed the last thing I pointed out before I submitted it
What you are doing now is also wrong though.
Inside your find constructor you should be assigning fileName and all of the other class attributes to the values coming in from the constructor. If you just leave the values hardcoded in the constructor you have you will never have an object with different data unless you manually switch the code.
Hope this helps,
"If the facts don't fit the theory, get new facts" --Albert Einstein
Anyway i wanted to say thank you, your examples were very helpful.
Altho this morning I read your post from yesterday evening had myself a can of Red Bull and a little read on arguements from the Oracle site and wrote myself a solution lol. I was soo chuffed lol im sure its no biggy but I was pretty happy. Anyway below is what I've used.