I am very very new to java and trying to extend File class to add some more methods and properties to it with below class
import java.io.File;
public class RecordingFile extends File {
private static final long serialVersionUID = -4774703382591639948L;
String RecordingNameFormatted;
String RecordingDurationFormatted;
String RecordingSizeFormatted;
String RecordingDateFormatted;
String RecordingBitrateFormatted;
public RecordingFile(String path) {
super(path);
File f = new File(path);
RecordingNameFormatted = f.getName().replace(".mp3", "");
RecordingDurationFormatted = Utils.millisecondsToHours(Utils.getMp3DurationPureJava(f));
RecordingSizeFormatted = Utils.humanReadableByteCount(f.length(), true);
RecordingDateFormatted = Utils.longToDate(f.lastModified());
RecordingBitrateFormatted = Utils.getBitratePureJava(f) +"Kbps";
}
}
Above doesn't work properly. I am not even sure if
File f = new File(path);
supposed to be there. For example when I try this
ArrayList<RecordingFile> ret = new ArrayList<RecordingFile>();
RecordingFile filesDir = new RecordingFile(path);
if (!filesDir.exists()) {
filesDir.mkdirs();
}
RecordingFile[] list = filesDir.listFiles();
Eclipse tells me that "Type mismatch: cannot convert from File[] to RecordingFile[]" How can i just extend File class by adding couple more properties/methods to it?