1. Engineering
  2. Computer Science
  3. java project please show solution create a netbeans project for...

Question: java project please show solution create a netbeans project for...

Question details


  • Create a NetBeans project for this activity.

Consider the following code. Create a file, name it anything you want and paste the directory on the <insert file directory here> section of the code.

import java.io.*;

public class FileIOExercise {

public static void main(String args[]){

      FileInputStream fileInputStream = null;

      FileOutputStream fileOutputStream = null;

      try {

         fileInputStream = new FileInputStream(<insert file directory here>);

         fileOutputStream = new FileOutputStream("output.txt");

         int c;

         while ((c = in.read()) != -1) {



      }finally {

         if (fileInputStream != null) {



         if (fileOutputStream != null) {






Test Stem / Question


1: Try to compile the code. What is wrong with it?

A: There is compile error because of unreported exception.

B: There is a syntax error.

C: Compile error because of streams can’t be used this way.

D: run perfectly

2: Try to fix the error. What should you do?

A: Catch the exception or declare a throw statement.

B: Rename the local variables.

C: Remove the close statement of the fileOutputStream. Only input streams need to be closed.

D: Nothing

3: What exceptions do you need to catch or throw when dealing with Java IO?

  1. FileNotFoundException
  2. IOException
  3. InterruptedIOException

A: A, B & C

B: Only A & B

C: A Only

D: B only

4: Now that you have compiled and run the code? What happened?

A: The context of my input is copied from the output.txt

B: There a file not found exception since I did not define a output.txt directory.

C: Did not copy my input but no exception was thrown.

D: Compiler error.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution