My solution writes simultaneous to a file and console as excpected.
But there are for every write method a error message like that:
"Achte darauf, dass die Methode write(String str) throws IOException der FileConsoleWriter-Klasse die Daten auch auf die Konsole schreibt."
I don't know what's wrong.
Perhaps it belongs to that: "Die FileConsoleWriter-Klasse muss das Feld private clFileWriter fileWriter besitzen."
What is meant with the object-type clFileWriter with the name fileWriter? I used as object-type FileWriter.
Thank's for helping.
package de.codegym.task.task19.task1917;
/*
Dein eigener FileWriter
*/
import java.io.*;
public class FileConsoleWriter {
private FileWriter fileWriter;
private PrintWriter consoleWriter = new PrintWriter(System.out);
public FileConsoleWriter(String fileName) throws IOException {
this.fileWriter = new FileWriter(fileName);
}
public FileConsoleWriter(String fileName, boolean append) throws IOException {
this.fileWriter = new FileWriter(fileName, append);
}
public FileConsoleWriter(File file) throws IOException {
this.fileWriter = new FileWriter(file);
}
public FileConsoleWriter(File file, boolean append) throws IOException {
this.fileWriter = new FileWriter(file,append);
}
public FileConsoleWriter(FileDescriptor fd) {
this.fileWriter = new FileWriter(fd);
}
public void write(int c) throws IOException {
this.fileWriter.write(c);
this.consoleWriter.write(c);
}
public void write(char[] cbuf, int off, int len) throws IOException {
this.fileWriter.write(cbuf, off, len);
this.consoleWriter.write(cbuf, off, len);
}
public void write(String str, int off, int len) throws IOException {
this.fileWriter.write(str, off, len);
this.consoleWriter.write(str, off, len);
}
public void close() throws IOException {
this.fileWriter.close();
this.consoleWriter.close();
}
public void write(char[] cbuf) throws IOException {
this.fileWriter.write(cbuf);
this.consoleWriter.write(cbuf);
}
public void write(String str) throws IOException {
this.fileWriter.write(str);
this.consoleWriter.write(str);
}
public static void main(String[] args) throws IOException {
}
}