الرجوع
تسجيل الدخول

What does the following Java code do?

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class AppendToFile {
    public static void main(String[] args) {
        String fileName = "data.txt";
        try {
            PrintWriter outputStream = new PrintWriter(new FileWriter(fileName, true));
            outputStream.println("This is an appended line.");
            outputStream.close();
        } catch (IOException e) {
            System.out.println("An error occurred: " + e.getMessage());
        }
    }
}