Advertisement
Josif_tepe

Untitled

Mar 27th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class Main {
  4.     static long max_length = 0;
  5.     static File max_file = null;
  6.     static void rec(File at) {
  7.         File[] files = at.listFiles();
  8.         for(int i = 0; i < files.length; i++) {
  9.             if(files[i].isDirectory()) {
  10.                 rec(files[i]);
  11.             }
  12.             else {
  13.                 if(max_length < files[i].length()) {
  14.                     max_length = files[i].length();
  15.                     max_file = files[i];
  16.                 }
  17.             }
  18.         }
  19.     }
  20.     public static void main(String[] args) {
  21.         String filePath = "/Users/josiftepegjozov/Documents/test";
  22.         File S = new File(filePath);
  23.         rec(S);
  24.         System.out.println(max_file.toString());
  25.  
  26.         }
  27.  
  28.     }
  29.  
  30. // rec(folder: test)
  31. // rec(folder: test2)
  32. // rec(folder: test3)
  33. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement