Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication13;
- import java.util.*;
- import java.io.*;
- public class Main {
- public static void main(String[] args) {
- String Pfad = "C:/JavaAufgabe/";
- String str;
- List<String> liste = new ArrayList<String>();
- File f = new File(Pfad);
- File[] list = f.listFiles();
- for (File x : list){
- if (x.getName().endsWith(".txt")){
- liste.add(x.getName());
- }
- }
- for (String dateiname : liste){
- System.out.println("\nFolgende Datei wird ausgewertet: \n"+dateiname);
- int spaltenAuswertung = 0;
- try{
- BufferedReader bur = new BufferedReader(new FileReader(Pfad+dateiname));
- str=bur.readLine();
- int zaehler=1;
- while (str!=null){
- System.out.println("Zeile "+zaehler+": "+str);
- Scanner scanner = new Scanner(str);
- if (scanner.hasNextInt()) {
- spaltenAuswertung = spaltenAuswertung + scanner.nextInt();
- }
- str = bur.readLine();
- zaehler++;
- }
- bur.close();
- }catch(Exception eIO){}
- System.out.println("Summe der in der Datei beeinhalteten Zahlen numerischer Natur = "+spaltenAuswertung);
- if (spaltenAuswertung==1337){
- System.out.println("LEET Data found and marked :>");
- // new File(Pfad+Dateinamen[i]).renameTo(new File(Pfad+"1337_"+dateiname));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement