Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will check a Java file for syntax errors. The program will

ID: 3700014 • Letter: W

Question

Write a program that will check a Java file for syntax errors. The program will ask for an in file name and output-file name and will then copy all the code from the Java input file to the Java output file, but with the following changes: put- Any syntax error found in the Java input file will be corrected: o Missing compound statements (curly braces) o All comments have to start with// and end with a period Four spaces should be used as the unit of indentation. Tabs must be set exactly every 8 spaces (not 4). . You program should have a simple GUI (Graphical User Interface). Use ArrayList or LinkedList class to solve the problem. Thoroughly test your code for any possible input. Do not hardwire the output.

Explanation / Answer

As per your requirement the below one is solution please follow it step by step

import java.io.*;
class ShowFile {
public static void main(String args[])
throws IOException
{
int i;
FileInputStream fin;
try {
fin = new FileInputStream(args[0]);
} catch(FileNotFoundException e) {
System.out.println("File Not Found");
return;
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Usage: ShowFile File");
return;
}
// read characters until EOF is encountered
do {
i = fin.read();
if(i != -1) System.out.print((char) i);
} while(i != -1);
fin.close();
}
}

import java.io.*;
class CopyFile {
public static void main(String args[])
throws IOException
{
int i;
FileInputStream fin;
FileOutputStream fout;
try {
// open input file
try {
fin = new FileInputStream(args[0]);
} catch(FileNotFoundException e) {
System.out.println("Input File Not Found");
return;
}
// open output file
try {
fout = new FileOutputStream(args[1]);
} catch(FileNotFoundException e) {
System.out.println("Error Opening Output File");
return;
}
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Usage: CopyFile From To");
return;
}
// Copy File
try {
do {
i = fin.read();
if(i != -1) fout.write(i);
} while(i != -1);
} catch(IOException e) {
System.out.println("File Error");
}
fin.close();
fout.close();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote