Что валидатору надо?
Если что так тоже пробовал, все равно не принимает:
@Override
public void close() throws IOException {
fos.flush();
fos.write(string.getBytes());
fos.close();
}
И почему через Alt+insert конструктора с FileOutputStream fos не выдавало? В чем может быть причина?
package com.javarush.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 fos;
String string = "JavaRush © All rights reserved.";
public static void main(String[] args) throws FileNotFoundException {
new AmigoOutputStream(new FileOutputStream(fileName));
}
public AmigoOutputStream(FileOutputStream fos) throws FileNotFoundException {
super(fileName);
this.fos = fos;
}
@Override
public void write(int b) throws IOException {
fos.write(b);
}
@Override
public void write(byte[] b) throws IOException {
fos.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
fos.write(b, off, len);
}
@Override
public void close() throws IOException {
flush();
write(string.getBytes());
fos.close();
}
@Override
public void flush() throws IOException {
fos.flush();
}
}