Is something wrong with validating string or the exception is not thrown?
package com.codegym.task.task18.task1814;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
/*
UnsupportedFileName
*/
public class TxtInputStream extends FileInputStream {
public TxtInputStream(String fileName) throws IOException {
super(fileName);
checkString(fileName);
}
public static void main(String[] args) {
}
public void checkString(String fileName) throws IOException {
if (!fileName.endsWith(".txt")) {
try {
throw new UnsupportedEncodingException();
} catch (UnsupportedEncodingException e) {
super.close();
}
}
}
}