ONLY IN JAVA PLS Make as simple as possible Modify the attached program to read in the contents of "A Tale of Two Cities" (download from gutenberg.org) and store each word that is longer than 4 characters in an ArrayList. Use command line arguments for the file name and the minimum length (4). Print the first ten words and last ten words that are in your ArrayList. Upload your .java file and the output of running it. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Files { public static void main(String[] args) throws FileNotFoundException { int minimumStringLength = Integer.parseInt(args[1]); // Open the file. File file = new File("replaceMe"); Scanner inputFile = new Scanner(file); inputFile.useDelimiter("[^a-zA-Z]+"); // Read until the end of the file. while (inputFile.hasNext()) { String word = inputFile.next(); System.out.println(word); } // close the file when done. inputFile.close(); } }
ONLY IN JAVA PLS
Make as simple as possible
Modify the attached program to read in the contents of "A Tale of Two Cities" (download from gutenberg.org) and store each word that is longer than 4 characters in an ArrayList. Use command line arguments for the file name and the minimum length (4). Print the first ten words and last ten words that are in your ArrayList. Upload your .java file and the output of running it.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Files
{
public static void main(String[] args) throws FileNotFoundException
{
int minimumStringLength = Integer.parseInt(args[1]);
// Open the file.
File file = new File("replaceMe");
Scanner inputFile = new Scanner(file);
inputFile.useDelimiter("[^a-zA-Z]+");
// Read until the end of the file.
while (inputFile.hasNext())
{
String word = inputFile.next();
System.out.println(word);
}
// close the file when done.
inputFile.close();
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images