Created
March 10, 2020 09:32
-
-
Save Aleksandar1932/0ca9628ac76181e9e6cf7313c04035b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mk.ukim.finki.os.lab1; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.util.Arrays; | |
public class Problem4 { | |
public static final String filePath = "/home/aleksandar/Desktop/tmp/lab1.problem4"; | |
//Interval za golemina na fajl | |
public static final int BOTTOM_BOUND = 1 * 1024; | |
public static final int UPPER_BOUND = 100 * 1024; | |
public static void filterFilesInFolder(File folder) { | |
File[] filesArray = folder.listFiles(); | |
for (File file : filesArray) { | |
if (file.isDirectory()) { | |
filterFilesInFolder(file); | |
} | |
if (file.isFile() && (file.length() > BOTTOM_BOUND && file.length() < UPPER_BOUND) | |
&& (file.getName().endsWith(".txt") || file.getName().endsWith(".out"))) { | |
System.out.println(file.getAbsolutePath()); | |
} | |
} | |
} | |
public static void main(String[] args) throws FileNotFoundException { | |
File f = new File(filePath); | |
if (!f.exists()) { | |
throw new FileNotFoundException(); | |
} | |
if (!f.isDirectory()) { | |
throw new FileNotFoundException(); | |
} | |
filterFilesInFolder(f); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment