Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. package GUI;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.util.Scanner;
  6.  
  7. public class FileReaderDemo {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. FileReader fr = new FileReader("FileReaderDemo.java");
  12.  
  13. try {
  14.  
  15. File file = new File("C:/Users/grohale1/Test.txt");
  16. Scanner scan = new Scanner(file);
  17.  
  18. String strZeile="";
  19.  
  20. while ( scan.hasNextLine() ) {
  21. strZeile = scan.nextLine();
  22. System.out.println("Eingelesen: " + strZeile);
  23. }
  24. }
  25.  
  26. catch (FileNotFoundException e) {
  27. System.out.println("Datei existiert nicht!");
  28. }
  29.  
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement