Scanner: nextLine() : Scanner « java.util « Java by API






Scanner: nextLine()

 
import java.io.File;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws Exception{
    File file = new File("data.txt");

    Scanner scanner = new Scanner(file);
    while (scanner.hasNextLine()) {
      String line = scanner.nextLine();
      System.out.println(line);
    }
  }
}

   
  








Related examples in the same category

1.new Scanner(FileReader file)
2.new Scanner(InputStream source)
3.new Scanner(String instr)
4.new Scanner(Readable source)
5.Scanner: findInLine(String str)
6.Scanner: findWithinHorizon(String pattern, int horizon)
7.Scanner: hasNext()
8.Scanner: hasNextBoolean()
9.Scanner: hasNextDouble()
10.Scanner: hasNextInt()
11.Scanner: hasNextLine()
12.Scanner: next()
13.Scanner: nextBoolean()
14.Scanner: nextDouble()
15.Scanner: nextInt()
16.Scanner: useDelimiter(String pattern)