Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Java Code below needs to have comments added. Once you have correctly run and tested the program, comment in the source code where there

The Java Code below needs to have comments added. Once you have correctly run and tested the program, comment in the source code where there is a Comment Here statement. Also respond to the 3 challenge questions below. Be sure your response includes proper rationale to support your reasoning. Copy and paste completed code and type answers to challenge questions.

Code:

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

public class CopyFileContent {

public static void main(String[] args) {

/* Comment Here */

File sourceFile = new File("file1.txt");

/* Comment Here */

File destFile = new File("file2.txt");

/* Comment Here */

if (!destFile.exists()) {

try {

destFile.createNewFile();

} catch (IOException e) {

e.printStackTrace();

}

}

InputStream input = null;

OutputStream output = null;

try {

/* Comment Here */

input = new FileInputStream(sourceFile);

/* Comment Here */

output = new FileOutputStream(destFile);

byte[] buf = new byte[1024];

int bytesRead;

while ((bytesRead = input.read(buf)) > 0) {

output.write(buf, 0, bytesRead);

}

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

finally {

try {

if (null != input) {

input.close();

}

if (null != output) {

output.close();

}

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

Challenge Questions:

1. The services and functions provided by an operating system can be divided into two main categories. Briefly describe the two categories and discuss how they differ.

2. What are the five major activities of an operating system with regard to file management?

3.What is the main advantage for an operating-system designer of using a virtual-machine architecture? What is the main advantage for a user?

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

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

=+5 Does this case provide an example of the future for IHRM?

Answered: 1 week ago

Question

=+4 How did it affect HR?

Answered: 1 week ago