Question: The code provided below contains syntax and / or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors,

The code provided below contains syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
Code:
// Program reads in a file of phone numbers without area codes
// inserts "(312)" in front of each phone number
// and produces an output file with the new complete phone numbers
import java.nio.file.*;
import java.io.*;
import java.nio.channels.FileChannel;
import static java.nio.file.StandardOpenOption.*;
public class DebuggingExercise05{
public static void main(String[] args)
{
Path fileIn =
Paths.get("/root/sandbox/DebugData2.txt");
Path fileOut =
Paths.get("/root/sandbox/DebugData2New.txt");
String areaCode ="(312)";
String phone;
InputStream input = nul;
OutputStream output = nul;
try
{
input = Files.newInputStream(fileIn);
BufferedReader reader = BufferedReader
(new InputStreamReader(input));
output = Files.newOutputStream(fileOut);
phone = reader.readLine();
while(phone = null)
{
phone = areaCode + phone + System.getProperty("line.separator");
byte phoneBytes = phone.getBytes();
output.write(phoneBytes);
phone = reader.readline();
}
input.closes();
output.closes();
}
catch (IOException e)
{
System.out.println(e);
}
}
}

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!