Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.Scanner;
- public class HW01_1 {
- public static void main(String[] args) {
- Scanner jin = new Scanner(System.in);
- checkTxtSize(jin.nextLine());
- jin.close();
- }
- private static void checkTxtSize(String input) {
- File[] files = new File(input).listFiles();
- double size = 0;
- int count = 0;
- for (int i = 0; i < files.length; i++) {
- if(files[i].isFile()&&files[i].getName().substring(files[i].getName().lastIndexOf(".")+1).equals("txt")){
- size += files[i].length();
- count++;
- }
- }
- System.out.println(String.format("%.2f", size/count));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement