package sk.upjs.paz1a.task07;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.nio.file.FileAlreadyExistsException;
import sk.upjs.jpaz2.Turtle;
public class TurtleCommander extends Turtle {
public void listDirectory(File adresar) {
String[] obsahAdresaru = adresar.list();
for (int i = 0; i < obsahAdresaru.length; i++) {
System.out.println(obsahAdresaru[i]);
}
}
public int countFiles(File adresar) {
int pocet = 0;
File[] subory = adresar.listFiles();
for (int i = 0; i < subory.length; i++) {
if (subory[i].isFile()) {
pocet++;
}
}
return pocet;
}
public long totalSizeOfFilesInDirectory(File adresar) {
long sucet = 0;
File[] subory = adresar.listFiles();
for (int i = 0; i < subory.length; i++) {
if (subory[i].isFile()) {
sucet = sucet + subory[i].length();
}
}
return sucet;
}
public void punishment(File output, String message, int n) {
// nedokoncene
try {
PrintWriter pw = new PrintWriter(output);
pw.println("Ahoj");
} catch (FileNotFoundException e) {
}
}
}