且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用扫描仪从文本文件中读取字符串,然后打印出

更新时间:2023-01-11 19:54:46

使用下面的代码,扫描仪接下来仅给出一个单词,使用nextLine代替读取整行.

use below code, scanner next gives just a word use nextLine instead to read whole line..

Scanner scan = new Scanner(file);
            String str1 = scan.nextLine();

                if(str1.equals("!-   ===========  ALL OBJECTS IN CLASS: FENESTRATIONSURFACE:DETAILED ==========="))
                    System.out.println(str1);
                scan.close();