SlideShare a Scribd company logo
1 of 3
Download to read offline
// 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 java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
public class DebugThirteen2
{
public static void main(String[] args)
{
Path fileIn =
Paths.get(C:JavaChapter.13DebugData3.txt);
Path fileOut =
Paths.get(C:JavaChapter.13DebugData3New.txt);
String areaCode = "(312) ";
String phone;
InputStream input = null;
OutputStream output = null
try
{
input = Files.newInputStream(fileIn);
BufferedReader reader = new BufferedReader
(new InputStreamReader(input);
output = Files.newOutputStream(fileOut);
phone = input.readLine();
while(phone == null)
{
phone = areaCode + phone + System.getProperty("line.separator");
byte[] phoneBytes = phone.getBytes();
output.writeln(phoneBytes);
phone = reader.readline();
}
input.close();
}
catch (IOException e)
{
System.out.println(e);
}
}
}
Solution
Hi,
I have fixed the code. Highlighted the code changes below
DebugThirteen2.java
import java.nio.file.*;
import java.io.*;
public class DebugThirteen2
{
public static void main(String[] args)
{
Path fileIn =
Paths.get("C:JavaChapter.13DebugData3.txt");
Path fileOut =
Paths.get("C:JavaChapter.13DebugData3New.txt");
String areaCode = "(312) ";
String phone;
InputStream input = null;
OutputStream output = null;
try
{
input = Files.newInputStream(fileIn);
BufferedReader reader = new 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.close();
}
catch (IOException e)
{
System.out.println(e);
}
}
}

More Related Content

Similar to Program reads in a file of phone numbers without area codes .pdf

Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
arshiartpalace
 
Assignment 2Assignment Content1. Top of FormResource·.docx
Assignment 2Assignment Content1. Top of FormResource·.docxAssignment 2Assignment Content1. Top of FormResource·.docx
Assignment 2Assignment Content1. Top of FormResource·.docx
braycarissa250
 
Use arrays to store data for analysis. Use functions to perform the .pdf
Use arrays to store data for analysis. Use functions to perform the .pdfUse arrays to store data for analysis. Use functions to perform the .pdf
Use arrays to store data for analysis. Use functions to perform the .pdf
footworld1
 
Cis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential files
CIS321
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
Shahjahan Samoon
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
shahidqamar17
 
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdfTask #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
info706022
 
Write a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdfWrite a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdf
udit652068
 

Similar to Program reads in a file of phone numbers without area codes .pdf (20)

ExtraFileIO.pptx
ExtraFileIO.pptxExtraFileIO.pptx
ExtraFileIO.pptx
 
Complete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docxComplete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docx
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
Assignment 2Assignment Content1. Top of FormResource·.docx
Assignment 2Assignment Content1. Top of FormResource·.docxAssignment 2Assignment Content1. Top of FormResource·.docx
Assignment 2Assignment Content1. Top of FormResource·.docx
 
Phonebook
PhonebookPhonebook
Phonebook
 
In JavaWrite a program that reads a text file that contains a gra.pdf
In JavaWrite a program that reads a text file that contains a gra.pdfIn JavaWrite a program that reads a text file that contains a gra.pdf
In JavaWrite a program that reads a text file that contains a gra.pdf
 
ch06-file-processing.ppt
ch06-file-processing.pptch06-file-processing.ppt
ch06-file-processing.ppt
 
Use arrays to store data for analysis. Use functions to perform the .pdf
Use arrays to store data for analysis. Use functions to perform the .pdfUse arrays to store data for analysis. Use functions to perform the .pdf
Use arrays to store data for analysis. Use functions to perform the .pdf
 
Cis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential filesCis 170 c ilab 7 of 7 sequential files
Cis 170 c ilab 7 of 7 sequential files
 
File Handling.pptx
File Handling.pptxFile Handling.pptx
File Handling.pptx
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
JAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docxJAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docx
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
 
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdfTask #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
Task #1 Correcting Logic Errors in FormulasCopy and compile the so.pdf
 
Write a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdfWrite a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdf
 
Os lab final
Os lab finalOs lab final
Os lab final
 
File in cpp 2016
File in cpp 2016 File in cpp 2016
File in cpp 2016
 
• GUI design using drag and drop feature of IDE(Net beans), • File IO
•	GUI design using drag and drop feature of IDE(Net beans), •	File IO•	GUI design using drag and drop feature of IDE(Net beans), •	File IO
• GUI design using drag and drop feature of IDE(Net beans), • File IO
 
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/OCore Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
 
Lab4
Lab4Lab4
Lab4
 

More from nitinarora01

Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdfChapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
nitinarora01
 
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
An Overview of Transport Mechanisms In Plants.  Relate the structure .pdfAn Overview of Transport Mechanisms In Plants.  Relate the structure .pdf
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
nitinarora01
 
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdfamazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
nitinarora01
 
37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf
nitinarora01
 
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdfWhich property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
nitinarora01
 
What roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdfWhat roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdf
nitinarora01
 
What are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdfWhat are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdf
nitinarora01
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdf
nitinarora01
 
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdfQuestion 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
nitinarora01
 

More from nitinarora01 (20)

Describe the movement of yeast cells once ingested by a paramecium &.pdf
Describe the movement of yeast cells once ingested by a paramecium &.pdfDescribe the movement of yeast cells once ingested by a paramecium &.pdf
Describe the movement of yeast cells once ingested by a paramecium &.pdf
 
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdfChapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
Chapter 2 problems.1.            (Problem 1) Of the following, whi.pdf
 
By equity . Party A owns a factory that emits large quantities of f.pdf
By equity . Party A owns a factory that emits large quantities of f.pdfBy equity . Party A owns a factory that emits large quantities of f.pdf
By equity . Party A owns a factory that emits large quantities of f.pdf
 
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
An Overview of Transport Mechanisms In Plants.  Relate the structure .pdfAn Overview of Transport Mechanisms In Plants.  Relate the structure .pdf
An Overview of Transport Mechanisms In Plants. Relate the structure .pdf
 
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdfamazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
amazon.com & pinterest.com -- Web 2.0 ApplicationsAddress how eac.pdf
 
All organelles (check all that apply) Are membrane bound Contain th.pdf
All organelles (check all that apply)  Are membrane bound  Contain th.pdfAll organelles (check all that apply)  Are membrane bound  Contain th.pdf
All organelles (check all that apply) Are membrane bound Contain th.pdf
 
A study designed to evaluate the effect of the herbal remedy Echinac.pdf
A study designed to evaluate the effect of the herbal remedy Echinac.pdfA study designed to evaluate the effect of the herbal remedy Echinac.pdf
A study designed to evaluate the effect of the herbal remedy Echinac.pdf
 
37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf37. If the material below the sandstone of problem 26 is a shale with.pdf
37. If the material below the sandstone of problem 26 is a shale with.pdf
 
Why didnt implementation of robots in the 1980s continue to increas.pdf
Why didnt implementation of robots in the 1980s continue to increas.pdfWhy didnt implementation of robots in the 1980s continue to increas.pdf
Why didnt implementation of robots in the 1980s continue to increas.pdf
 
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdfWhich property of life (e.g. homeostasis) is illustrated by each of .pdf
Which property of life (e.g. homeostasis) is illustrated by each of .pdf
 
Which of the following statements is FALSE regarding microbial mats.pdf
Which of the following statements is FALSE regarding microbial mats.pdfWhich of the following statements is FALSE regarding microbial mats.pdf
Which of the following statements is FALSE regarding microbial mats.pdf
 
What roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdfWhat roles do membranes play in a cellWhat are cell membranes com.pdf
What roles do membranes play in a cellWhat are cell membranes com.pdf
 
26. The gecko is a reptile that has the amazing ability to climb smo.pdf
26. The gecko is a reptile that has the amazing ability to climb smo.pdf26. The gecko is a reptile that has the amazing ability to climb smo.pdf
26. The gecko is a reptile that has the amazing ability to climb smo.pdf
 
What is soft trend vs. hard trend Analyze a specific software engin.pdf
What is soft trend vs. hard trend Analyze a specific software engin.pdfWhat is soft trend vs. hard trend Analyze a specific software engin.pdf
What is soft trend vs. hard trend Analyze a specific software engin.pdf
 
what does it mean to be a social scientistSolutionSocial .pdf
what does it mean to be a social scientistSolutionSocial .pdfwhat does it mean to be a social scientistSolutionSocial .pdf
what does it mean to be a social scientistSolutionSocial .pdf
 
What are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdfWhat are the advantages for proteins to form three-dimensional struc.pdf
What are the advantages for proteins to form three-dimensional struc.pdf
 
Weather List the types of materials used to create a concrete sidewal.pdf
Weather List the types of materials used to create a concrete sidewal.pdfWeather List the types of materials used to create a concrete sidewal.pdf
Weather List the types of materials used to create a concrete sidewal.pdf
 
The OSI Reference Model layers, in order from top to bottom, areA.pdf
The OSI Reference Model layers, in order from top to bottom, areA.pdfThe OSI Reference Model layers, in order from top to bottom, areA.pdf
The OSI Reference Model layers, in order from top to bottom, areA.pdf
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdf
 
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdfQuestion 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
Question 1 (1 point)Tjhe pH of blood is __________ and when the .pdf
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Recently uploaded (20)

The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 

Program reads in a file of phone numbers without area codes .pdf

  • 1. // 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 java.nio.ByteBuffer; import static java.nio.file.StandardOpenOption.*; public class DebugThirteen2 { public static void main(String[] args) { Path fileIn = Paths.get(C:JavaChapter.13DebugData3.txt); Path fileOut = Paths.get(C:JavaChapter.13DebugData3New.txt); String areaCode = "(312) "; String phone; InputStream input = null; OutputStream output = null try { input = Files.newInputStream(fileIn); BufferedReader reader = new BufferedReader (new InputStreamReader(input); output = Files.newOutputStream(fileOut); phone = input.readLine(); while(phone == null) { phone = areaCode + phone + System.getProperty("line.separator"); byte[] phoneBytes = phone.getBytes(); output.writeln(phoneBytes); phone = reader.readline(); } input.close();
  • 2. } catch (IOException e) { System.out.println(e); } } } Solution Hi, I have fixed the code. Highlighted the code changes below DebugThirteen2.java import java.nio.file.*; import java.io.*; public class DebugThirteen2 { public static void main(String[] args) { Path fileIn = Paths.get("C:JavaChapter.13DebugData3.txt"); Path fileOut = Paths.get("C:JavaChapter.13DebugData3New.txt"); String areaCode = "(312) "; String phone; InputStream input = null; OutputStream output = null; try { input = Files.newInputStream(fileIn); BufferedReader reader = new BufferedReader (new InputStreamReader(input)); output = Files.newOutputStream(fileOut); phone = reader.readLine(); while(phone != null) {
  • 3. phone = areaCode + phone + System.getProperty("line.separator"); byte[] phoneBytes = phone.getBytes(); output.write(phoneBytes); phone = reader.readLine(); } input.close(); } catch (IOException e) { System.out.println(e); } } }