用过的读写

Posted Orc_Warrior

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用过的读写相关的知识,希望对你有一定的参考价值。

1、从文件中读取三行数据

String[] lines = new String[3];
boolean readPointerFileSuccess = true;

try (Scanner scanner = new Scanner(pointerFile)) {
    for (int i = 0; i < lines.length; i++) {
        if (scanner.hasNextLine()) {
            lines[i] = scanner.nextLine();
        } else {
            readPointerFileSuccess = false;
        }

    }
}

 

以上是关于用过的读写的主要内容,如果未能解决你的问题,请参考以下文章