My problem is as follows ... I have used regex pattern and matcher to loop through a text file and write to another. When i use matcher.start and matcher.end it returns the matched pattern but when I try to append the new string at this position I want it is appended to the end of the text file only
I need to be able to append at a pos matcher.end +1(which could be in the middle of a text file)
Is this possible? - I am using filewriter to achieve this
I am grateful for any help at all - Thanks
Julian Kennedy
Ranch Hand
Joined: Aug 02, 2004
Posts: 823
posted
0
I'm not sure that I really understand your post, but have you considered RandomAccessFile?
Jules
Paul Sheehan
Greenhorn
Joined: Aug 05, 2004
Posts: 3
posted
0
Thanks for replying Jules
I have solved the problem, but just for clarity I will retry and explain the problem I had
I would search through text file1 , constantly writing to text file2 until the character # was found. I then had to append a string (bla) to the end of the # mark before writing to text file2 - so text file1 would still have only # in it, where as textfile2 would have #bla in it
My problem was the logic of my loop, using a string instead of manipulating a stringbuffer and writing the stringbuffer to text file 2 This meant that #bla was always being appended to the very end of text file2 instead of at the position of #
Thanks anyway for replying jules, perhaps the best way to have done this was using randomAccess but I was in a real rush to get this done
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: jav filewriter appending to text file at pos x