Advertisement
Guest User

Untitled

a guest
May 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. package javaapplication13;
  2.  
  3. import java.util.*;
  4. import java.io.*;
  5.  
  6. public class Main {
  7.  
  8.  
  9. public static void main(String[] args) {
  10.  
  11. String Pfad = "C:/JavaAufgabe/";
  12. String str;
  13. List<String> liste = new ArrayList<String>();
  14.  
  15. File f = new File(Pfad);
  16. File[] list = f.listFiles();
  17.  
  18. for (File x : list){
  19. if (x.getName().endsWith(".txt")){
  20. liste.add(x.getName());
  21. }
  22. }
  23.  
  24. for (String dateiname : liste){
  25. System.out.println("\nFolgende Datei wird ausgewertet: \n"+dateiname);
  26. int spaltenAuswertung = 0;
  27. try{
  28. BufferedReader bur = new BufferedReader(new FileReader(Pfad+dateiname));
  29. str=bur.readLine();
  30. int zaehler=1;
  31. while (str!=null){
  32. System.out.println("Zeile "+zaehler+": "+str);
  33. Scanner scanner = new Scanner(str);
  34. if (scanner.hasNextInt()) {
  35. spaltenAuswertung = spaltenAuswertung + scanner.nextInt();
  36. }
  37. str = bur.readLine();
  38. zaehler++;
  39. }
  40. bur.close();
  41. }catch(Exception eIO){}
  42.  
  43. System.out.println("Summe der in der Datei beeinhalteten Zahlen numerischer Natur = "+spaltenAuswertung);
  44. if (spaltenAuswertung==1337){
  45. System.out.println("LEET Data found and marked :>");
  46. // new File(Pfad+Dateinamen[i]).renameTo(new File(Pfad+"1337_"+dateiname));
  47. }
  48.  
  49. }
  50.  
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement