prepend 2 lines to an existing shell script using java

Hi:

I have a shell script such as

#!/bin/sh

#author ...

#goal ...

set CMDARGS = ...

Now, I need to add 2 lines to this file before the set command so that the script looks like

#!/bin/sh

#author ...

#goal ...

Line 1

Line 2

set CMDARGS = ...

Essentially, Line 1 will be the first line of the script after the comments. How can I do this using File IO in java 1.5?

Thanks.

[461 byte] By [Nish_Ba] at [2007-11-26 17:42:17]
# 1

There no special I/O methods to insert lines into the middle of a file.

I would do the obvious:

1. Read from a BufferedReader

2. Open a temporary file and write to a BufferedWriter,

inserting the new lines where they should go.

3. Delete the original file and rename the new one to take its place.

DrLaszloJamfa at 2007-7-9 0:10:28 > top of Java-index,Java Essentials,Java Programming...