Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 andor 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 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 DebuggingExercise
public static void mainString args
Path fileIn
Paths.getrootsandboxDebugDatatxt;
Path fileOut
Paths.getrootsandboxDebugDataNew.txt;
String areaCode ;
String phone;
InputStream input nul;
OutputStream output nul;
try
input Files.newInputStreamfileIn;
BufferedReader reader BufferedReader
new InputStreamReaderinput;
output Files.newOutputStreamfileOut;
phone reader.readLine;
whilephone null
phone areaCode phone System.getPropertylineseparator";
byte phoneBytes phone.getBytes;
output.writephoneBytes;
phone reader.readline;
input.closes;
output.closes;
catch IOException e
System.out.printlne;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started