首页 > 代码库 > 用过的读写

用过的读写

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;
        }

    }
}

 

用过的读写