Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 which is returned from the method.

* 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, and return the ArrayList from the method.

* 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 getCleanContent() {

ArrayList lines = new ArrayList();

//TODO Implement method

return lines;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

When are objects on the periphery of your vision most noticeable?

Answered: 1 week ago

Question

Why is time important in a competitive environment?

Answered: 1 week ago

Question

=+b) State the hypotheses.

Answered: 1 week ago

Question

Express the following ratios in its lowest terms.

Answered: 1 week ago

Question

Express the following ratios in its lowest terms.

Answered: 1 week ago

Question

Express the following ratios in its lowest terms.

Answered: 1 week ago