I think this could work but it obviously calls super first and maybe I have to control "endwith" argument first ... For this I don't know how to do because I'm forced to call super first ...
package fr.codegym.task.task18.task1814;
import java.io.*;
import java.nio.channels.FileChannel;
/*
UnsupportedFileName
*/
public class TxtInputStream extends FileInputStream {
public TxtInputStream(String fileName) throws IOException, UnsupportedFileNameException {
super(fileName);
if (!fileName.endsWith("txt")) {
super.close();
throw new UnsupportedFileNameException();
}
}
@Override
public int read() throws IOException {
return super.read();
}
@Override
public int read(byte[] b) throws IOException {
return super.read(b);
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
return super.read(b, off, len);
}
@Override
public long skip(long n) throws IOException {
return super.skip(n);
}
@Override
public int available() throws IOException {
return super.available();
}
@Override
public void close() throws IOException {
super.close();
}
@Override
public FileChannel getChannel() {
return super.getChannel();
}
public static void main(String[] args) {
}
}