Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA question Rearrange the following lines to produce statements that read a file and print all words in the file, one per line to another
JAVA question
Rearrange the following lines to produce statements that read a file and print all words in the file, one per line to another file, with lines numbered 1., 2., 3., and so on. Mouse: Drag/drop Keyboard: Grab/release Spacebar (or Enter). Move Cancel Esc Unused ReadAFile.java Load default template... in.close(); out.close(); out.println(counter + import java.util.Scanner; import java.io.PrintWriter; import java.io.File; import java.io.FileNotFoundException; ".." + word); int counter = 0; Scanner in = new Scanner(new File("input.txt")); public class ReadAFile { public static void main (String [] args) throws FileNotFoundException { String word = in.next(); PrintWriter out = new PrintWriter("words.txt"); counter++; while (in.hasNext() { } 1 }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