Appending to a text file


Saturday, November 11, 2023 Difficulty: Easy

Objective

Create a Java program that asks the user for lines until you press Enter.

The lines should be updated at the end of the text file if it exists, but a new file should be created.

Input

dapibus
pretium
radar

Output

Solution

Click here to view the exercise solution

Share it

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

Copied

The code has been successfully copied to the clipboard.

More Exercises

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

1

Write to a text file

Create a program in Java to request lines from the user and write them in a text file.

2

Read a text file

Create a Java program that reads a text file and displays all its lines on the screen.

3

Appending to a text file

Create a Java program that asks the user for lines until you press Enter.

4

Convert a text file to uppercase

Write a program in Java to read a text file and make a copy in another file by changing the lowercase letters to uppercase.

5

Count the words in a file

Create a program in Java to count the number of words stored in a text file.

6

Encrypt a text file

Create a Java program that makes a copy of a text file but encrypted.

7

Search lines in a text file

Create a Java program that reads the contents of a text file and stores it in an array of strings.

8

Reverse text from a file

Create a Java program that makes a copy of a text file but reverse all its content.

9

More program

Create a Java program that behaves like the Unix more command, you must display the contents of a text file and ask the user to press Enter every time the screen is full.

Text Files

Practice with exercises in Java to manage text files. Learn how to create, update, and search text files in different ways.

Practice exercises

Keep learning

C# Programming Course

Free programming course with practical exercises and solutions in C#. Start learning right now!

Exercises C# App

Take your Exercises C# lessons everywhere with our Android app. Download it now from Google Play