0% found this document useful (0 votes)
4 views3 pages

Student Writer Project

This assignment requires writing structured student records to a text file using Java. Students must create a class named StudentFileWriter, utilize List<String> and file-handling classes, and ensure proper exception handling. The program should write specific student data to 'student_records.txt' and display a success message or an error message as appropriate.

Uploaded by

elijah2009w
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 views3 pages

Student Writer Project

This assignment requires writing structured student records to a text file using Java. Students must create a class named StudentFileWriter, utilize List<String> and file-handling classes, and ensure proper exception handling. The program should write specific student data to 'student_records.txt' and display a success message or an error message as appropriate.

Uploaded by

elijah2009w
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

Java Programming Assignment

Writing Student Records to a Text File


Objective

In this assignment, you will practice file output in Java by writing structured student data to a
text file. You will use file-handling classes to store formatted student records in an external .txt
file.

This assignment reinforces:

●​ List<String> usage
●​ The [Link]() method
●​ File writing using PrintWriter or FileWriter
●​ Exception handling (try-catch or throws IOException)
●​ Proper program structure and formatting

Provided Data
Your program must use the following data exactly as written:

Java
List<String> students = [Link](
"Alice Smith, 1001, Intro to Java, A",
"Bob Johnson, 1002, Data Structures, B+",
"Charlie Brown, 1003, Algorithms, C",
"Diana Prince, 1004, Operating Systems, A-"
);

Program Requirements
1️⃣ Create a Class

Create a class named:

None
StudentFileWriter

2️⃣ Write Data to a File

Your program must:

●​ Create a file named:

None

student_records.txt

●​ ​
Write all student records into the file
●​ Each student record must appear on its own line
●​ Preserve formatting exactly as shown

3️⃣ Use Proper File Handling

You must:

●​ Use either:
○​ PrintWriter
○​ FileWriter
○​ OR a combination of both
●​ Properly close the file
●​ Handle possible exceptions using:
○​ try-catch
○​ OR throws IOException

4️⃣ Console Output


After successfully writing to the file, display:

None
Student records successfully written to file.

If an error occurs, display a meaningful error message.

Required Methods
Your program must include:

●​ public static void main(String[] args)


●​ At least one additional method:

Example:

None
public static void writeToFile(List<String> students)

Sample Output in student_records.txt


None
Alice Smith, 1001, Intro to Java, A
Bob Johnson, 1002, Data Structures, B+
Charlie Brown, 1003, Algorithms, C
Diana Prince, 1004, Operating Systems, A-

You might also like