我试图提示用户输入文件名并搜索文件名并将其保存为2个二维数组。
文件示例为:
BBBBB
BBBBB
BBBBB
BBBBB
public class maze_2D{
static Scanner s = new Scanner(System.in);
public static void FromFile() throws Exception{//
System.out.println("Enter File name");
String file = s.nextLine();
File f = new java.io.File(file);
Scanner scanner = new Scanner(f);
// Read from file.....
但是当我运行程序时,我收到错误
Enter Filename
java.io.FileNotFoundException:
为什么会发生这种情况,为什么这个扫描仪不允许我输入任何文件名?
答案 0 :(得分:0)
在命令提示符下输入文件名时,会在文件系统中为#using a stub to facilitate accessing the URLs later with
# an absolute address
stub = 'https://www.beeradvocate.com'
beer <- read_html(paste0(stub, '/lists/top/'))
lnx = beer %>% html_nodes('a') %>% html_attr('href') %>%
#this pattern matches beer profile links --
# the first . is a brewery ID, the second .
# is a beer ID within that brewery
grep('profile/.*/.*/', ., value = TRUE) %>%
paste0(stub, .)
head(lnx)
# [1] "https://www.beeradvocate.com/beer/profile/23222/78820/"
# [2] "https://www.beeradvocate.com/beer/profile/28743/136936/"
# [3] "https://www.beeradvocate.com/beer/profile/28743/146770/"
# [4] "https://www.beeradvocate.com/beer/profile/28743/87846/"
# [5] "https://www.beeradvocate.com/beer/profile/863/21690/"
# [6] "https://www.beeradvocate.com/beer/profile/17981/110635/"
提供文件所在的full path
。
file name with extension
答案 1 :(得分:0)
我使用你的大部分代码制作了一个小小的广告,它工作得很好...尝试检查你的路径+文件名,以确保它真的存在。
我听说过scanner.getInteger强制你在它之后添加一个scanner.nextLine(),但你正在使用nextLine到fileName所以不应该这样。
{{1}}