In this task, is it generally possible to avoid creating two objects of the FileInputStream class as in my code? public class TxtInputStream extends FileInputStream { public TxtInputStream(String fileName) throws Exception { super(fileName); if (fileName.endsWith(".txt")) { new FileInputStream(fileName); } else { super.close(); throw new UnsupportedFileNameException(); } }