小编sav*_*24x的帖子

从文本文件Java读取行?

所以我是Java的新手,我正在尝试的一切都没有用.有很多不同的方法可以从文件中读取,所以我想知道最简单的方法.基本上,它是一个疯狂的Libs应用程序.一种方法.我一直试图成功运行它,我在file.close()函数上得到一个错误.如果我拿走它,我会FileNotFoundException errors.所以我有点迷茫.我应该改变什么?

public static void main(String[] args) throws Exception {
    String[] nouns = new String[4];
    String[] verbs = new String[6];
    String[] adjectives = new String[7];
    Scanner s = new Scanner(System.in);
    System.out.println("Please input 4 nouns, press \"Enter\" after each input.");
    for(int i=0; i<4; i++){
        nouns[i] = s.next();
    }
    System.out.println("Please input 6 verbs, press \"Enter\" after each input.");
    for(int i=0; i<6; i++){
        verbs[i] = s.next();
    }
    System.out.println("Please input 7 adjectives, press \"Enter\" after each input.");
    for(int i=0; i<7; …
Run Code Online (Sandbox Code Playgroud)

java file

2
推荐指数
1
解决办法
6027
查看次数

标签 统计

file ×1

java ×1