Everything seems okay, but then also need a little help
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";
FileOutputStream fs;
public AmigoOutputStream(FileOutputStream fs) throws FileNotFoundException{
super(fileName);
this.fs = fs;
}
public static void main(String[] args) throws FileNotFoundException {
new AmigoOutputStream(new FileOutputStream(fileName));
}
@Override
public void write(byte[] b) throws IOException{
fs.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException{
fs.write(b, len, off);
}
@Override
public void write(int b) throws IOException{
fs.write(b);
}
@Override
public void flush() throws IOException{
fs.flush();
}
@Override
public void close() throws FileNotFoundException, IOException{
fs.flush();
String toAppend = "CodeGym © All rights reserved.";
fs.write(toAppend.getBytes());
fs.close();
}
}