Reference no: EM131588685
Managing Error Handling and Files
Before you attempt this section, review the concept of Files from your text book. Double-Click on the IDE (Eclipse or Java Beans) on your desktop as directed by your Instructor. Once you launch your IDE, close the WELCOME page. You are now ready to follow the instructions below:
We are going to use PROGFIVE to read data from a file and then write data to a file. Note that file is read to a BufferedReader. We also need to set the filename to a value. Before, you start your coding, you need to create a file with text and store it in documents in the virtual lab. Type the following in the text file using Notepad.
It is a wonder day at Ashford University. I am in this class to learn Java and more precisely, how to use file. If I am working with files, I have completed 4 previous programs. I am not sure if it has been fun but it has been interesting.
Save the file as myfile.txt
Open Eclipse as you have done in the past and start coding. Create a new project called PROGFIVE and within the project create a class called testfiles (remember right click on src). The code below has minor errors that you will have to fix on your own. The errors are intentional. Also, do not just copy this code, try to rewrite using classes and methods.
Start a Java project
import java.io.*; //needed to handle files
public class testFiles {
public static void main(String[] args) {
String fileName = "myfile.txt"; //you need to include the full file path in between " "
// This will reference one line at a time
String line = null;
//below is the error handling if the file does not exist
try {
System.out.println("place your name here");
FileReader fileReader = new FileReader(fileName);
BufferedReader bufferedReader = new BufferedReader(fileReader);
while((line = bufferedReader.readLine()) != null) {
System.out.println(line)
}
bufferedReader.close(); //closing file after processing
}
//error if the file does not exits
catch(FileNotFoundException ex) {
System.out.println("Unable to open file ‘');
}
catch(IOException ex) {
System.out.println( "Error reading file ")
}
}
}
Now you are ready to run your code.
Create a program that accepts a 10-digit phone number
: Create a program that accepts a 10-digit phone number (no 1 in front) and tells the user if the message is a toll-free number.
|
Determining the understanding structure
: Write pseudocode that describes the process of guessing a number between 1 and 100. After each guess, you should tell the player whether the guess.
|
How might this have influenced his behavior
: Try to "connect the dots" between what was happening at Arthur Andersen and Enron, and discuss how each business entity's set of events was separate
|
What are the differences between a z-test and an anova
: What are the differences between an independent t-test, a dependent t-test, a z-test, an ANOVA, an ANCOVA?
|
Managing error handling and files
: review the concept of Files from your text book. Double-Click on the IDE (Eclipse or Java Beans) on your desktop as directed by your Instructor
|
Why the lease meets the capital lease requirements
: Please write a memo to your boss (me) discussing the reason why the lease meets the capital lease requirements
|
Discusses four types of perceptual distortions
: Discusses four types of perceptual distortions- stereotyping, halo effects, selective perception, and projection. Define each of these and provide an example
|
Create a sexual harassment policy
: Create a sexual harassment policy for your selected company to address a sexual harassment complaint.
|
Describe the types of computer hardware
: For this essay, describe the types of computer hardware and software your employees will use, the type of network setup you will need between the two offices
|