The text book I am using is introduction to java programming 9th edition by Lian
ID: 3531306 • Letter: T
Question
The text book I am using is introduction to java programming 9th edition by Liang
Programming exercise 19.12 at page 734 of the textbook. IMPORTANT: Please use Java from command line ONLY for question 4A. Copy the screenshots of your execution from command line and paste to your submitted report. (Combine files) Write a utility program that combines the files together into a new file using the following command: java Exercisel9_12 SourceFilel . . . SourceFilen TargetFile The command combines SourceFilel. . . . , and SourceFilen into TargetFile. Programming exercise 19.13 at page 735 of the textbook. (Combine files GUI) Rewrite Exercise 19.12 with a GUI, as shown in Figure 19.20b. Figure 19.20b is as follows:Explanation / Answer
solution for exercise 19.12.it is detailed please rate with 5 star
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class Exercise19_12 {
public static void main(String[] args) throws Exception {
// Check usage
if (args.length < 2) {
System.out.println(
"Usage: java Exercise19_12 SourceFile1 ... SoureFilen TargetFile");
System.exit(1);
}
// The last file TargetFile is for output
BufferedOutputStream output = new BufferedOutputStream(
new FileOutputStream(new File(args[args.length - 1])));
for (int i = 0; i < args.length - 1; i++) {
BufferedInputStream input = new BufferedInputStream(
new FileInputStream(new File(args[i])));
int value;
while ((value = input.read()) != -1) {
output.write(value);
}
input.close();
}
output.close();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.