Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions