program requests and reads a list of file names (one per line). Program ends when a blank line is entered.
If a file name endsWith ".txt" then print "Text File: xxxx" where xxxx is the full file name. If the file name contains the string "del" print "Delete: xxxx". If the file satisfies both conditions just do the text file option. Otherwise do not print anything.
So far I have done this but I can't figure out how to do the part where you output Text file: if it contains both .txt and del. Could anyone help me out?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package assignment2;
import java.util.Scanner;
/**
*
* @author Adam
*/
public class FileType {
public static void main(String[] args) {
String fileNames = "";
Scanner scan = new Scanner(System.in);
System.out.println("Enter file names (blank line to end):");
fileNames = scan.nextLine();
while (fileNames.contains(".txt")) {
System.out.println("Text File:" + fileNames);
fileNames = scan.nextLine();
while (fileNames.contains("del")) {
System.out.println("Delete:" + fileNames);
fileNames = scan.nextLine();
}
}
}
}