File Handling Introduction

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

FILE HANDLING INTRODUCTION

File handling introduction

You'll be provided with a file that contains the data in CSV format. Using FileReader,
read the file and parse the data contained in it to the below-specified format.

Provided "input.csv" which has User details. Read all the user information stored in CSV
format and create a user object by parsing the line. Add all the user objects to the
ArrayList. At last, display the user list.

Strictly adhere to the Object-Oriented specifications given in the problem statement. All class
names, attribute names, and method names should be the same as specified in the problem
statement.

Consider the class called User with the following private attributes


Attributes Datatype
name String
email String
username String
password String

Consider UserBO class and define the following methods


Method Name Description
This method accepts the BufferedRea
public List<User> readFromFile(BufferedReader br)
in the file to User objects and adds them to a list.
This method accepts a list of User objects
public void display(List<User> list)
Use "%-15s %-20s %-15s %s\n" to print the detail

Consider the class Main. If the List of Users is empty print " The list is empty" in the main
method. Else display the user detail by calling the display method.

Note : Use BufferedReader br=new BufferedReader(new FileReader("input.csv")) for


file reading.

The link to download the template code is given below


Code Template

Input format:

Read the input from the "input.csv" file which contains the user details.
Output format:

Use "%-15s %-20s %-15s %s\n" to print statements for the heading of the details in the
Main method.

Sample Input: (input.csv)

Sample Output :

Name            Email                Username        Password


William             will@gmail.com        william             will123
john           john@gmail.com     john           abc

You might also like