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...


Please answer question. This is pertaining to Java programming language


3-15


Given the following code and Fileln.txt, what will be the contents of FileOut.txt, if<br>any?<br>Assume that the Fileln.txt file exists in the directory where the program is being run<br>and that the program has permission to write files to that directory.<br>Example input file:<br>Fileln.txt<br>Here<br>is<br>some text<br>even more<br>

Extracted 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.*;<br>import java.util.Scanner;<br>public class FileIO {<br>public static void main(String[] args) {<br>try {<br>File in<br>= new File(

Extracted 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!"); } } }

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here