Question 2 Design an application that can be used to read DVD titles from a text
ID: 3742412 • Letter: Q
Question
Question 2 Design an application that can be used to read DVD titles from a text file. You do not have to write to the file, only write code to read the titles of DVDs from a text file called DVD.txt. Create the text file with at least four DVD titles in the file as shown in the sample file below. (Marks: 20) dvd.tt-Notepad File Edit Format View Help Android Programming calculus Explained web Development with PHP Learn C After the file has been read the following output will be shown: Output-ReadFromFile (run) Android Programming Calculus Explained Web Development with PHP Learn C# BUILD SUCCESSFUL (total time:4 seconds) ! Make use of exception handling in your application. Save your application as ReadFromFile.java END OF PAPERExplanation / Answer
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ReadFromFile { public static void main(String[] args) { try { Scanner fin = new Scanner(new File("dvd.txt")); while (fin.hasNextLine()) { System.out.println(fin.nextLine()); } fin.close(); } catch (FileNotFoundException e) { System.out.println("can not open dvd.txt to read"); } } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.