Lab 02

File I/O Problems

 

Objective:

 

Write a solution that performs file input and output (File I/O) using a variety of file types and problems.

 

Lab Solution

 

Requirements:

 

 

 

Example Dialog:

Welcome to the File I/O Problem's Solutions!

Enter 1. For Test 1

Enter 2. For Test 2

Enter 9. To Quit

1

 

-----------------------

Test01

-----------------------

Testing method "pastTense" with the file "ItIs.txt" and outputting to "ItWas.txt"

What

was

it?

It

was

something

after

all,

and

something

was

not

nothing.

How

was

it

described?

was

it

big?

was

it

small?

was

it

green

or

was

it

purple

or

was

it

neither?

was

this

it

or

was

that

it?

Who

knows?

Enter 1. For Test 1

Enter 2. For Test 2

Enter 9. To Quit

2

 

-----------------------

Test02

-----------------------

Testing method "totalTubeVolume" with the file "./Tubes.txt"

The total combined volume is: 20106.51499622167

 

Enter 1. For Test 1

Enter 2. For Test 2

Enter 9. To Quit

9

Goodbye!

Solution Tests:

  1. Is your name written as a comment in all source files?
  2. Does the solution compile (no syntax errors)?
  3. When running the driver, do you get the same output as the Example Dialog?

 

Lab Report

 

  1. Create a section named “Problem” and describe this lab’s problem in your own words. (10pts).
  2. Create a section named “Solution Description” and describe how the code solves the problem in your own words. (10pts).
  3. Create a section named “Problems Encountered” and describe the various syntax, run-time, and logic errors that were encountered while implementing the solution. (10pts).
  4. Describe the difference between absolute and relative file paths (10pts)
  5. In terms of file paths, what does “./” mean? (10pts)
  6. In this course, where should all files that are to be read from or printed to be placed? (10pts)
  7. What important detail must one do when finished either reading from or writing to a file? (10pts)
  8. Describe the purpose of “delimiters / separators” used in file formats. (10pts)
  9. Looking at the below code snippet, it is supposed to read a tab-delimited file, parse the information, and process the data. The method “process” works correctly, but there is something wrong with how the file is being read. It seems to read it word-by-word instead of line-by-line, so what could be causing this problem and how can it be fixed? (10pts)

 

  1. Looking at the below code snippet, its purpose is to append all the values in the array “someData” to the file “output.txt”. However, this code does not append to the file, but rather erases and overwrites all the data previously in the file. How can this code be fixed so that the information is appended? (10pts)

 

 

Finally

Upload the Lab Solution’s source code (.JAVA file(s)) and the Lab Report’s text file to the CSCE Dropbox.