202-33P - Programming Lab Java-Algorithm - Appending Text to an Existing File
202-33P - Programming Lab Java-Algorithm - Appending Text to an Existing File
Algorithm:
Aim: Appending text to the existing file
Step No. Instructions
1 Start
2 Create a file named “new.txt” using edit command in DoS
3 Open a random access file named “new.txt” in the Read Write mode using the
function RandomAccessFile( ).
4 Move to the starting location in the file using seek( ) function
5 Read the contents from Keyboard using BufferedReader( )/ DataInputStream ( ) and
readLine( ) functions
6 Append the contents into the file using writeBytes( ) fuction
7 Close the file.
Now the file is updated successfully
8 Save the program in the name of list12.java
9 Compile the program using javac
10 Run the program using java
11 Enter the text and check whether text is appended or not using type command
12 Stop