23 lines
509 B
Java
23 lines
509 B
Java
package org.FileExamples.ReadingFiles;
|
|
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.util.Scanner;
|
|
|
|
public class ReadFileExample01 {
|
|
static void main() {
|
|
File file = new File("quotes.txt");
|
|
try {
|
|
Scanner reader = new Scanner(file);
|
|
|
|
while(reader.hasNext())
|
|
{
|
|
String line = reader.nextLine();
|
|
System.out.println(line);
|
|
}
|
|
} catch (FileNotFoundException e) {
|
|
|
|
}
|
|
}
|
|
}
|