Question: Below is a Java code that copies one file into another. Use the strace feature (in Linux or Windows) to summarize trace result in terms

Below is a Java code that copies one file into another. Use the strace feature (in Linux or Windows) to summarize trace result in terms of system calls on your operating system. A paragraph that includes some of these system calls will suffice.

package copydemo;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

public class CopyDemo

{

public static void main(String[] args)

{

FileInputStream instream = null;

FileOutputStream outstream = null;

try{

File infile =new File("InputFile.txt");

File outfile =new File("OutputFile.txt");

instream = new FileInputStream(infile);

outstream = new FileOutputStream(outfile);

byte[] buffer = new byte[1024];

int length;

/*copying the contents from input stream to

* output stream using read and write methods

*/

while ((length = instream.read(buffer)) > 0){

outstream.write(buffer, 0, length);

}

//Closing the input/output file streams

instream.close();

outstream.close();

System.out.println("File copied successfully!!");

}

catch(IOException ioe)

{

ioe.printStackTrace();

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!