0% found this document useful (0 votes)
4 views

202-33P - Programming Lab Java-Algorithm - Appending Text to an Existing File

The document outlines a Java program that appends text to an existing file named 'new.txt'. It provides a step-by-step algorithm that includes creating the file, opening it in read-write mode, reading user input, appending the input to the file, and closing the file. Finally, it instructs the user to compile and run the program to verify the appended text.

Uploaded by

Suraj Ladkat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

202-33P - Programming Lab Java-Algorithm - Appending Text to an Existing File

The document outlines a Java program that appends text to an existing file named 'new.txt'. It provides a step-by-step algorithm that includes creating the file, opening it in read-write mode, reading user input, appending the input to the file, and closing the file. Finally, it instructs the user to compile and run the program to verify the appended text.

Uploaded by

Suraj Ladkat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

12. Write a Java Program which open an existing file and append text to that 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

You might also like