Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
File I/O Lab | CS 159 CS 159 Docs Labs Projects Labs Lab 01 - Eclipse Lab Lab 02 - Memory Lab Lab 03 - Two-Dimensional Arrays Lab Lab 04 - Debugger Lab Lab 05 - Class Design Lab Lab 06 - ArrayList Lab Lab 07 - File I/O Lab View page source Edit this page Create child page Create documentation issue Print entire section Introduction Resources Files Instructions - Part 1 Instructions - Part 2 Instructions - Part 3 (If Time) Submitting Tag Cloud .equals1 .jar1 .toString1 2D-array2 accessor1 activation record1 arguments1 array3 arraylist1 checkstyle2 class design1 CLI2 command line2 constructor1 data modeling1 debugger1 docs1 document2 eclipse3 editor2 exceptions1 file2 format2 gradescope1 heap1 input1 install1 jdk1 junit3 lab1 load1 memory1 mutator1 OOP1 output1 overload1 override1 project4 project11 project21 project31 read1 save1 setup1 stack1 stub1 test1 tutor1 unit test2 validate1 visualizer1 write1 Categories Docs2 Lab8 Project4 Labs Lab 07 - File I/O Lab File I/O Lab Tags: file input output command line CLI document editor unit test junit Categories: Lab   2 minute read   Introduction The goal of this lab is to practice working with Java file I/O by adding load/save functionality to the Document class you completed in a previous lab. The code for this lab was originally designed as a command-line Java application so you may want to run it in the terminal. It is also fine to run it through the Eclipse console. As a reminder, you can follow the following steps to compile and execute a Java program in a Linux/OSX terminal: cd the_directory_where_your_code_is_stored javac File1.java File2.java ... java File1 This example assumes that File1.java contains the main method for the application. Resources Useful API documents: java.util.Scanner java.io.File java.io.PrintWriter Files The following unfinished files are provided: Document.java Editor.java Instructions - Part 1 Download the files above and complete Document.java so that the unfinished methods conform to the Javadoc comments. Test your completed file by running the provided application program. Instructions - Part 2 The current implementation of the Editor class does not include code for handling exceptions related to file I/O: If you attempt to open a non-existent file, or to write a file to a location where do not have permission, the application will crash. Modify Editor.java by removing all throws declarations and adding try/catch blocks to saveFile and loadFile. If an exception occurs, these methods should print a helpful error message and then allow execution to proceed normally. Instructions - Part 3 (If Time) Most text editors allow you to save the current document without re-entering the file name. Modify the Editor class so that it provides this functionality. If the file is already associated with a file name (because of an earlier save or load) then the “s” command should now save the current version without prompting for a file name. You should also add a save-as command to allow specifying a file name even if one already exists. Use “w” to trigger save-as. Make sure to update the help message to conform to the new functionality. Submitting Submit your completed versions of Document.java and Editor.java to Gradescope . You have an unlimited number of submissions. If you have trouble with your submission, you may find it helpful to look at the JUnit submission tests: DocumentTestWithIO.java EditorTest.java Last modified February 24, 2022: fixed typos and added stubs (b84328e) © 2022 The Docsy Authors All Rights Reserved Privacy Policy About Goldydocs