Asked by J. Michael Berner on Jul 15, 2024
Verified
Write a Java method that returns a String representing a file name entered by the user.Use the BufferedReader class to obtain input.
BufferedReader
A class in Java used to read text from an input stream efficiently by buffering characters.
String
A series of symbols employed to signify text within the realm of computer coding.
- Construct Java script intended for both inputting and outputting data through file manipulation.
Verified Answer
XC
Xavier ClemmonsJul 22, 2024
Final Answer :
public static String getFileName)throws IOException
{
BufferedReader stdin = new BufferedReadernew
InputStreamReaderSystem.in));
System.out.print"Enter the name of the file to open: ");
String fileName = stdin.readLine);
return fileName.trim);
}
{
BufferedReader stdin = new BufferedReadernew
InputStreamReaderSystem.in));
System.out.print"Enter the name of the file to open: ");
String fileName = stdin.readLine);
return fileName.trim);
}
Learning Objectives
- Construct Java script intended for both inputting and outputting data through file manipulation.