It tells me to throw exception... I don't know what to do here
package com.codegym.task.task18.task1813;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/*
AmigoOutputStream
*/
public class AmigoOutputStream extends FileOutputStream {
public static String fileName = "C:/tmp/result.txt";
private FileOutputStream file;
public AmigoOutputStream(FileOutputStream file) throws Exception{
super(fileName);
this.file = file;
}
@Override
public void write(int b)throws IOException{
file.write(b);
}
@Override
public void write(byte[] b)throws IOException{
file.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException{
file.write(b, off, len);
}
public void flush() throws IOException{
file.flush();
}
public void close() throws IOException{
file.flush();
String toAppend="CodeGym © All rights reserved.";
write(toAppend.getBytes());
file.close();
}
public static void main(String[] args) throws FileNotFoundException, IOException {
try{
AmigoOutputStream amigo = new AmigoOutputStream(new FileOutputStream(fileName));
amigo.close();
}catch(Exception e){
System.out.println("I catch am");
}
}
}