Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FilenameFilter;
- public class HW01_1 {
- public static void main(String [] args) {
- if(args.length==0) {
- System.out.println("Ne e vneseno nishto");
- return;
- }
- File directory=new File(args[0]);
- if(!directory.exists()) {
- System.out.print("Ne postoi takov fajl");
- return;
- }
- if(!directory.isDirectory()) {
- System.out.print("Fajlot so toa ime ne e directory");
- return;
- }
- File [] files=directory.listFiles(new FilenameFilter(){
- @Override
- public boolean accept(File a,String name) {
- return name.endsWith(".txt");
- }
- });
- int zbir=0;
- for(File f:files)
- zbir+=f.length();
- double prosek=((double)zbir)/files.length;
- System.out.println("Vkupnata golemina na fajlovite e:"+ zbir+" a prosekot e: "+ prosek+"bajti");
- }
- }
Add Comment
Please, Sign In to add comment