ICT373: Lab Session FOUR
(All questions are important)
1. Write a static method which is given a String and decides whether a file of that name (in the local directory) can be opened as a text file for reading. The program can actually open the file and close it again without altering it. It should return a Boolean answer. Add a main test method in the class which allows the user to enter the name of the file and reports whether the file can be opened for reading.
2. Write a similar method which returns the number of characters in a text file. (Return –1 if the file doesn’t open.)
Copyright By PowCoder代写 加微信 powcoder
3. Write a similar method which returns the number of words in a text file. (Return –1 if the file doesn’t open.)
4. Copy SimplApp.java from attachments and get it to run.
5. Modify SimplApp to make a new program TextFileCharAndWordCounter which displays a GUI to allow the user to enter a String and press a button. The GUI should say whether there is a local file of that name which can be opened for input as a text file and, if so, it should report how many characters and how many words the file has.
6. Look at the Java documentation (or see Deitel 10th Ed. textbook Chapter 15.6, pp 712-715) for javax.swing.JFileChooser class and modify your TextFileCharAndWordCounter to make a new program which provides a file and directory “browsing” dialog to allow the user to select a text file.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com