Do you know how to read lines of a file? Do you know how to write lines to a file?
The basic algorithm is this:
1) read ====
2) if there are no more lines available abort
3) read 4 lines
4) combine those 4 lines into one line
5) write that line
6) go to step 1
If you use a Scanner the reading and checking can be done using nextLine() and hasNextLine().