Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fourletterwordpercent;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.util.ArrayList;
- import java.util.Scanner;
- /**
- *
- * @author Jacob Keenan
- */
- public class FourLetterWordPercent {
- public static void main(String[] args) {
- System.out.println("Please enter the name of a text file.");
- ArrayList<String> words = new ArrayList<>();
- ArrayList<String> fourLetters = new ArrayList<>();
- Scanner keyIn = new Scanner(System.in);
- String fileName = keyIn.next();
- File inputFile = new File(fileName + ".txt");
- FileReader fr;
- try
- {
- Scanner list = new Scanner(inputFile);
- fr = new FileReader(inputFile);
- while (list.hasNext())
- {
- words.add(fileName);
- }
- System.out.println(words);
- }
- catch (FileNotFoundException e)
- {
- System.out.println("Couldn't find that file. Sorry!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement