Have two methods in a class (below). All of my coding is under the process(Strin
ID: 3546078 • Letter: H
Question
Have two methods in a class (below). All of my coding is under the process(String fileName) method. I need some assistance with the process(Reader reader) method. I need to be able to take the input convert it to a string and then run the process(String fileName) method. I have having trouble building the try/catch under the process(Reader reader) method to convert the input to a string and run the code I built for a String input.
public int process(Reader reader)
{
.....
}
public int process(String fileName)
{
.....
}
Explanation / Answer
public int process(Reader reader)
{
Scanner s = new Scanner(reader).useDelimiter("\A");
String s2="";
if (s.hasNext())
{
s2=s.next();
}
// use your s2 variable in further code...
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.