Given the following code and Fileln.txt, what will be the contents of FileOut.txt, if any? Assume that the Fileln.txt file exists in the directory where the program is being run and that the program has permission to write files to that directory.
Given the following code and Fileln.txt, what will be the contents of FileOut.txt, if any? Assume that the Fileln.txt file exists in the directory where the program is being run and that the program has permission to write files to that directory.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Please answer question. This is pertaining to Java
3-15

Transcribed Image Text:Given the following code and Fileln.txt, what will be the contents of FileOut.txt, if
any?
Assume that the Fileln.txt file exists in the directory where the program is being run
and that the program has permission to write files to that directory.
Example input file:
Fileln.txt
Here
is
some text
even more
![import java.io.*;
import java.util.Scanner;
public class FileIO {
public static void main(String[] args) {
try {
File in
= new File("FileIn.txt");
= new File("FileOut.txt");
File out
Scanner sc = new Scanner(in);
PrintWriter pw = new Printwriter(out);
int i = 1;
while (sc.hasNextLine()) {
if ( i % 2 == 1 ) {
sc. nextline();
pw.println("This was an odd line
i++;
} else {
pw.println(sc.nextLine());
i++;
}
+ i);
}
pw.close();
} catch (FileNotFoundException fe) {
System.out.println("File not found");
} finally {
System.out.println("Whew, finally done!");
}
}
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F37ffeb4c-90e5-4cb9-a6b6-d76475059d8f%2Fa292c7e2-1d25-4ccb-8923-daa3ea913ce5%2Fkirt5zb_processed.png&w=3840&q=75)
Transcribed Image Text:import java.io.*;
import java.util.Scanner;
public class FileIO {
public static void main(String[] args) {
try {
File in
= new File("FileIn.txt");
= new File("FileOut.txt");
File out
Scanner sc = new Scanner(in);
PrintWriter pw = new Printwriter(out);
int i = 1;
while (sc.hasNextLine()) {
if ( i % 2 == 1 ) {
sc. nextline();
pw.println("This was an odd line
i++;
} else {
pw.println(sc.nextLine());
i++;
}
+ i);
}
pw.close();
} catch (FileNotFoundException fe) {
System.out.println("File not found");
} finally {
System.out.println("Whew, finally done!");
}
}
}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps with 4 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY