【发布时间】:2018-11-06 20:41:47
【问题描述】:
因此,如果您继续使用我的 createdChoice 方法,您会看到我正在尝试弄清楚如何在文件中输入 User 并查看它是否存在。
这是我目前所拥有的。
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class MadLibs {
public static void main(String [] args) throws FileNotFoundException {
Scanner console = new Scanner(System.in);
File madLibFile = new File("/Users/adanvivero/IdeaProjects/Assignment 4/src/mymadlib.txt");
Scanner madLib = new Scanner(System.in);
String choice = menu(console);
if(choice.equals("c")) {
createdChoice(madLib);
}
}
public static void createdChoice(Scanner madLib) throws FileNotFoundException {
File madLibFile = new File("/Users/adanvivero/IdeaProjects/Assignment 4/src/mymadlib.txt");
Scanner input = new Scanner(System.in);
Scanner fileName = new Scanner(madLibFile);
System.out.print("Input file name: ");
String fileAccess = input.next();
//fileName = madLibFile;
if(fileAccess.equals(fileName)) {
System.out.print("Well this file exists, but I don't know how to make it into a scanner");
}
}
}
我希望这是有道理的。提供一些反馈
【问题讨论】:
-
我知道一个更简单的方法来做到这一点。有时间我会发的。