how to write them in separate text files

I have a text file having the following content:

......

end

............

...........

...................

end

............................

.........

end

What I'm trying to do is to divide the content of the file into several pieces just by the keyword "end", and then write each piece into a separate text file. Could anybody teach me how to implement this. Thank you very much!

[445 byte] By [Wenxiaoa] at [2007-10-2 10:16:59]
# 1

assuming end will always be on its own line

1. Create a bufferedreader on a FileReader of the file you're opening

2. Open up a file for writing (see PrintWriter and FileWriter)

3.

BufferedReader in = ...;

while ((line = in.readLine()) != null) {

if (line.equals("end")) // close the old file and open a new one

out.println(line)

}

4. Close all your files

tjacobs01a at 2007-7-13 1:42:47 > top of Java-index,Java Essentials,Java Programming...