View the step-by-step solution to:

Our prof only showed us one example about how to use FileIOnow she wants us to write one. I'm so confused about how to set it up.

Our prof only showed us one example about how to use FileIO,now she wants us to write one. I'm so confused about how to set it up. I knew the general concepts, like how to use fileReader and BufferedReader and close them, but I don't know how to put these pieces together.


Here are all the instructions she gave us:

FileIO.java must contain the following public static method:

• readCharacter() method.

This method takes as input a filename as a String parameter, and returns a new Character, using the constructor defined in the Character class.

The readCharacter method must use a FileReader and a BufferedReader in order to open the file specified by the filename. Make sure to catch FileNotFoundException and IOException when reading from the file. If either exception is raised, print an appropriate error message and return null.

You can assume that the files that readCharacter receives as input have all the same format: they contain 4 lines, with the following information

- Name of the character

- Attack value

- Maximum health

- Number of wins so far in the battle game

Examples of such files are the player.txt and the monster.txt files are provided with the assign- ment. Use the readLine() method of the BufferedReader to retrieve the content of the file. Use the information retrieved to create and return the appropriate object of type Character. 


We need to read two files, one called player, the information it contains are: Odin10.030.00

Another one called Fenrir12.030.03


Thanks for helping me out!

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question