import java.awt.*;
import java.io.File;
import java.io.FileFilter;

/**
 * Created by Vol4ica on 14.06.2015.
 */
public class OnelineRecursion
{

    File f;

    public OnelineRecursion(File f) { this.f = f; }

    public File getF() { return f;    }

    public void setF(File f) { this.f = f;    }

    public static void init(File p)
    {
        long size = 0;
        int number = 0;
        countSize(p, size);
        countNumber(p, number);
    }
public static int countNumber(File parent, int number){
    File[] files = parent.listFiles();

    for (File f : files) {
        if (f.isFile())
        {
            number=addNumber(number, 1);
        }
        else if (f.isDirectory()) {
            String a = f.getAbsolutePath();
            File b = new File(a);
            number += countNumber(b, 0);
        }
    }
    System.out.println("Number=" + number);
    return number;
}
    public static int addNumber(int n1,int n2)
    {
        int n=n1+n2;
        return n;
    }

public static long countSize(File parent, long size) {
    File[] files = parent.listFiles();

    for (File f : files) {
                if (f.isFile()) {
                    size = addSize(size, f.length());
                                 }
                else if (f.isDirectory()) {
                    String a = f.getAbsolutePath();
                    File b = new File(a);
                    size += countSize(b, 0);
                   }
            }
    System.out.println("Size=" + size);
    return size;
}
    public static long addSize(long s1,long s2)
    {
        long s=s1+s2;
        return s;
    }

    }

