Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am using NetBeans, can you help me with this? Tools - any . Screen 1-2 of 8 - View Options * X Close .

I am using NetBeans, can you help me with this?

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Tools - any . Screen 1-2 of 8 - View Options * X Close . Compress the NetBeans project into .rar or zip format and then Week011 - File IO upload to the link provided in the LMS. . Only NetBeans project compressed in .rar or .zip format will be accepted. Laboratory Exercise 010 Consider the following code. Create a file, name it Objective/s: anything you want and paste the directory on the At the end of this activity, you should be able to: section of the code. Use input/output stream import java. io.*; Learn how to use the different method and classes for input and public class FileIOExercise { output applications public static void main (String args ) { FileInputStream fileInputStream = What to Prepare for the Activity: null ; FileOutputStream fileOutputStream = . NetBeans IDE 8.2 null; . JDK8 (Java Development Kit 8) try { fileInputStream = new Procedure: FileInputStream () ; should be as follows: fileOutputStream = new FileOutputStream ("output. txt") ; Project Name: Lab010_ Example: Lab010_Blanco_Maria int c; while ( (c = in. read () ) != -1) { O e 42 f O N O 7:29 PM 10/11/2020Tools - aby . Screen 3-4 of 8 - View Options * X Close out . write (c) ; unreported exception. C: Compile error because of streams can't be used this way. }finally { if (fileInputStream != null) { fileInputStream. close () ; D: run perfectly if (fileOutputStream != null) ( 2: Try to fix the error. What A: Catch the exception or declare a throw should you do? statement. fileOutputStream. close () ; Remove the close statement of the fileOutputStream. Only input streams B: Rename the local variables. need to be closed. C: Remove the close statement of the fileOutputStream. Only input streams need to be closed. D: Nothing 3: What exceptions do you need to A: A, B & C catch or throw when dealing with Java IO? B: Only A & B Test Stem / Question Choices A. FileNotFoundException B. IOException C: A Only 1: Try to compile the code. What is | A: There is compile error because of unreported exception. C. InterruptedIOException wrong with it? B: Only A & B D: B only A: There is compile error because of B: There is a syntax error. 4: Now that you have compiled A: The context of my input is copied from O e 42 f O N O m 7:30 PM 10/11/2020* Tools - anz . Screen 5-6 of 8 - View Options * X Close and run the code? What the output.txt happened? B: There a file not found exception B: There a file not found exception since I File dir = new File () ; C: Did not copy my input but no exception items = was thrown. dir. D: Compiler error. for (File item : items) { System . out . println (item. Consider the following code. Our goal is to be able to print all the files in the given directory by completing the codes. Choose or create a folder with files in it. Add the directory in the section. Test Stem / Question Choices import java. io. 5: In order to use the class A: File and methods of File. What public class FileIo { should we import? B: FileClass A: File C: Files public static void main (String args ) { O e (42 f O N O 7:30 PM 10/11/2020* Tools - aby Screen 7-8 of 8 - View Options * X Close D: Streams 9: Now that we have A: It listed all the path inside the completed the code, try to directory. 6: In order to list all the A: listFiles() run it. What is the result? files and directories inside C: Compiler error since we B: Compiler error since we did not the File instance, what did not use the try catch method should you use in B: getFiles() throw or catch an exception. statements B? C: Compiler error since we did not C: getAllFiles() C: getAllFiles() use the try catch statements D: getDirectories() D: Nothing 7: What is the return type A: An array of File object A: exists() of that method? 10: Going back to the code, we would like to C: An array of Object object B: Collection of File object check if there is a file B: isPresent() present. What method C: An array of Object object should you use? C: isAvailable() C: isAvailable() D: An Array of string directories D: isValidDirectory() 8: In D, we would like to A: getAbsolutePath() get the absolute path of the Files. What method should you use? B: getAbsoluteFilePath() B: getAbsoluteFilePath() C: toAbsolutePath() D: toAbsoluteFilePath() O e O N O 7:30 PM 42 10/11/2020

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions