关闭

Write some Java Software

这项目被授予 gertheine ,费用为€30 EUR

为像这样的项目获取免费报价
雇主工作
项目预算
€30 - €250 EUR
全部竞标
6
项目描述

The objective of this

program will be to write to and read from a text file. There will be two classes developed –

“ReadWrite” and “InvalidFileTypeException”.

ReadWrite Class

o This class will handle the process of writing text to a file and reading from this text

file. It will have two fields named “file” and “text”.

o There should be one constructor and three methods in this class named “write”,

"writeToFile" and “read”

- Constructor:

o The constructor will request two String parameters 1. file (file to be written to) and 2.

text (text to be written).

- “write” method: (private)

o This method should write some text to the file specified in the constructor.

o The method should ensure that the file to be written to ends with the file extension -

".txt". If not, an "InvalidFileException" should be thrown.

o This method should claim (throw) two types of checked Exceptions.

- "writeToFile" method:

o This method should return "true" if the text is written successfully and "false"

if not.

o This method should invoke the "write" method.

o This method should catch at least two exceptions

 The exceptions should give the user a specific message about what

happened along with printing the stack trace to the console window.

- "read" method:

o This method will involve reading text from the text file.

o It will take one parameter - "fileToRead" - the name of the file to be read.

o You should output the text from this file to the console window.

o Ensure to incorporate Exception handling into this method also.

 If the file is not found - the exception object generated should return

the following message i.e. " filename (The system cannot find the file

specified)"

 If there's an I/O error - the relevant exception should be caught.

InvalidFileException Class

o You should develop a class named “InvalidFileException” class.

o This class should define a "Checked Exception".

o This exception should be implemented in the "ReadWrite" class.

o This class should contain a "toString" method which when called, will state :

Sorry, but this program only supports "text" files.

授予:
需要技能

浏览相关技能

相关项目

人们在Freelancer上干的其他事

相关文章

最新文章

在寻找赚取金钱的机会?

  • 设定您的预算和时间框架
  • 大致描述您的建议方案
  • 为您的工作领取工资

雇用同样在该项目上竞标的威客

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online