Question: import java.util.Scanner; import java.io.*; public class Main { // public static void main(String[] args) throws FileNotFoundException { try{ FileReader file = new FileReader(file3.txt); Scanner input
import java.util.Scanner; import java.io.*; public class Main { // public static void main(String[] args) throws FileNotFoundException { try{ FileReader file = new FileReader("file3.txt"); Scanner input = new Scanner(file); //Prints out the values in the document. Doesn't store them //while ( input.hasNext() ) // System.out.println(input.next()); //Storing values into an array String [] words = new String [1]; int i = 0; //index do{ //System.out.println(i); words[i] = input.next(); if(input.hasNext()){ //increase the size of words String [] temp = new String [words.length + 1]; for (int j = 0; j < words.length; j++) temp[j] = words[j]; words = temp; //replace the old with the new } i++; }while( input.hasNext() ); //words now holds all of the text in the document file System.out.println("Words has " + words.length + " items in it."); System.out.println("Words has " + words[0] + " as the first value."); //backwards! for (int k = words.length - 1; k >= 0; k--) { System.out.println(words[k] + " "); } //method calls go here. //end output input.close(); } catch (FileNotFoundException e){ System.out.println("File not found"); } }//ends main method //methods go below here //methods go above here }//ends the class Using this code, how do I insert the code you give me
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
