Задачу решил но так и не понял почему мы используем метод super в данном коде:
public class AmigoOutputStream extends FileOutputStream{
public static String fileName = "C:/tmp/result.txt";
private FileOutputStream file;
AmigoOutputStream(FileOutputStream file) throws FileNotFoundException{
super(fileName);
this.file = file;
}
public void flush() throws IOException{
file.flush();
}
public void write(int b) throws IOException{
file.write(b);
}
public void write(byte[] b) throws IOException{
file.write(b);
}
public void write(byte[] b, int off, int len) throws IOException{
file.write(b, off, len);
}
public void close() throws IOException{
file.flush();
String s = "JavaRush © All rights reserved.";
file.write(s.getBytes());
file.close();
}
public static void main(String[] args) throws FileNotFoundException {
new AmigoOutputStream(new FileOutputStream(fileName));
}
}
Uran Kulcharov
23 уровень
Задача решена, но есть вопрос
Обсуждается
Комментарии (1)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
IceBergMaster
24 июля 2019, 07:30
Это конструктор родительского класса.
0