Question
Please help me with the TODO, thank you. import java.util.ArrayList; /** * Class to read lines from a file. */ public class MyFileReader { /**
Please help me with the "TODO", thank you.
import java.util.ArrayList;
/**
* Class to read lines from a file.
*/
public class MyFileReader {
/**
* Name of file being read.
*/
private String filename;
/**
* Creates MyFileReader with given filename to read.
* @param filename to read
*/
public MyFileReader(String filename) {
this.filename = filename;
}
/**
* Opens the file specified by filename and reads the text line by line.
* Cleans up each line by trimming whitespace from the beginning and end of each line.
* Adds each line to an ArrayList
* If a line is empty (does not contain any text), it's skipped and is not added to the ArrayList
*
* Example:
* - Calling getCleanContent() will open and read the file, clean up the text line by line,
* add each line containing text to an ArrayList
* If there is a line "nice to meet you ", it will become "nice to meet you"
* If there is a line " hello world ", it will become "hello world"
* If there is a line "today is a nice day", it will remain "today is a nice day"
* If there is a line " ", it will be skipped and not added to the ArrayList
*
* @return list of lines with no empty spaces at the beginning or end of each line
*/
public ArrayList
ArrayList
//TODO Implement method
return lines;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started