Question
Create a NetBeans project named AddLineNumbers following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After
Create a NetBeans project named AddLineNumbers following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans project AddLineNumbers and before you attempt to execute your application download and/or copy the text data file dataInput.txt from the course Blackboard to the AddLineNumbers project folder. After you have created your NetBeans Project your application class should contain the following executable code:
package addlinenumbers;
public class AddLineNumbers {
public static void main(String[] args) { }
}
Write the code for the main class as indicated below:
package addlinenumbers;
/* Import the Scanner class and all classes from java.io */
// Your code here
public class AddLineNumbers {
public static void main( String [] args ) {
/* Declare variable identifiers to handle text data input from the file and count/increment the linenumber */
// Your code here
/* Start try block */
// Your code here
/* Instantiate Scanner object for data input from file dataInput.txt. There should be no path specification as your input file should be located in your AddLineNumbers project folder */
// Your code here
/* Instantiate a FileOutputStream object for file dataOutput.txt. Do not specify a path. Your file will be created in the project folder by NetBeans */
// Your code here
/* Instantiate a PrintWriter object for writing data to your FileOutputStram object */
// Your code here
/* Using a while loop control structure, read one line of data from input file, prepend the line number to data read from the file and output concatenated data to output file */
// Your code here
/* Close files and output message indicating the file has been written */
// Your code here
/* End try block */
/* Code FileNotFoundException and IOException catch blocks. Call getMessage(), toString() and printStackTrace() methods on exception object thrown */
// Your code here }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started