read data from a file in java

后端 未结 5 1175
被撕碎了的回忆
被撕碎了的回忆 2021-01-17 04:32

I have a text file in the following format:

Details.txt

The file is a .txt file. I want to read course title from this file and print corresponding textbook

5条回答
  •  [愿得一人]
    2021-01-17 05:16

    Use Scanner class

    Scanner s=new Scanner(new File("C:/Details.txt"));
    while(s.hasNext())
    {
      System.out.println(s.nextLine());
    }
    

    if you want in work by word then use String Tokenizer

    see this article

提交回复
热议问题