Skip to content

Instantly share code, notes, and snippets.

@Aleksandar1932
Created March 10, 2020 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aleksandar1932/0ca9628ac76181e9e6cf7313c04035b4 to your computer and use it in GitHub Desktop.
Save Aleksandar1932/0ca9628ac76181e9e6cf7313c04035b4 to your computer and use it in GitHub Desktop.
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