Advertisement
Benjamin_Loison

Treatement arma 3 heights

Jun 29th, 2018
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.util.Scanner;
  4.  
  5. public class Main
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.         Time.initializeTimer();
  10.         File currentFolder = new File(".");
  11.         File[] files = currentFolder.listFiles();
  12.         for(int i = 0; i < files.length; i++)
  13.         {
  14.             File file = files[i];
  15.             String fName = file.getName();
  16.             if(fName.endsWith(".block"))
  17.             {
  18.                 try
  19.                 {
  20.                     Disp.print("Working on: " + fName);
  21.                     Scanner scan = new Scanner(file);
  22.                     boolean usefull = false;
  23.                     while(scan.hasNextLine())
  24.                     {
  25.                         String line = scan.nextLine();
  26.                         String[] parts = line.split("@");
  27.                         for(int j = 0; j < parts.length; j++)
  28.                         {
  29.                             String part = parts[j];
  30.                             if(!part.equals("-185.97#7") && !part.equals("-185"))
  31.                             {
  32.                                 usefull = true;
  33.                             }
  34.                         }
  35.                     }
  36.                     scan.close();
  37.                     if(usefull)
  38.                     {
  39.                         Disp.print("File: " + fName + " has usefull info, conservating...");
  40.                     }
  41.                     else
  42.                     {
  43.                         Disp.print("File: " + fName + " hasn't usefull info, deleting...");
  44.                         file.delete();
  45.                     }
  46.                 }
  47.                 catch(FileNotFoundException e)
  48.                 {
  49.                     e.printStackTrace();
  50.                 }
  51.             }
  52.             else
  53.                 System.out.println("Don't work on: " + fName);
  54.         }
  55.         Disp.print("Work finished in " + Time.getExecuteTimeInMs() + " ms !");
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement