Some tip how to start or example of one method?
package pl.codegym.task.task19.task1917;
/*
Twój własny FileWriter
*/
import java.io.FileWriter;
import java.io.IOException;
public class FileConsoleWriter {
private FileWriter fileWriter;
public FileConsoleWriter(FileWriter fileWriter) {
this.fileWriter = fileWriter;
}
public void write(char[] cbuf, int off, int len) throws IOException{
fileWriter.write(cbuf, off, len);
}
public void write(int c) throws IOException{
fileWriter.write(c);
}
public void write(String str) throws IOException{
fileWriter.write(str);
}
public void write(String str, int off, int len) throws IOException{
fileWriter.write(str, off, len);
}
public void write(char[] cbuf) throws IOException{
fileWriter.write(cbuf);
}
public void close() throws IOException {
fileWriter.close();
}
public static void main(String[] args) {
}
}
/*
Twój własny FileWriter
Implementuj logikę FileConsoleWriter.
Klasa FileConsoleWriter musi posiadać prywatne pole clFileWriter o nazwie fileWriter.
Klasa FileConsoleWriter musi posiadać każdy konstruktor użyty do inicjalizowania fileWriter do zapisu.
Klasa FileConsoleWriter musi posiadać pięć metod write i jedną metodę close:
public void write(char[] cbuf, int off, int len) throws IOException
public void write(int c) throws IOException
public void write(String str) throws IOException
public void write(String str, int off, int len) throws IOException
public void write(char[] cbuf) throws IOException
public void close() throws IOException
Podczas zapisu danych do pliku, FileConsoleWriter musi zapisać dane również do konsoli.
Requirements:
1. Klasa FileConsoleWriter musi zawierać prywatne pole FileWriter o nazwie fileWriter,
które nie powinno być natychmiastowo inicjalizowane.
2. Klasa FileConsoleWriter musi posiadać pięć konstruktorów, które inicjalizują fileWriter do zapisu.
3. Klasa FileConsoleWriter musi posiadać metodę write(char[] cbuf, int off, int len) throws IOException,
która powinna zapisywać dane zarówno do fileWriter jak i do konsoli.
4. Klasa FileConsoleWriter musi posiadać metodę write(int c) throws IOException,
która powinna zapisywać dane zarówno do fileWriter jak i do konsoli.
5. Klasa FileConsoleWriter musi posiadać metodę write(String str) throws IOException,
która powinna zapisywać dane zarówno do fileWriter jak i do konsoli.
6. Klasa FileConsoleWriter musi posiadać metodę write(String str, int off, int len) throws IOException,
która powinna zapisywać dane zarówno do fileWriter jak i do konsoli.
7. Klasa FileConsoleWriter musi posiadać metodę write(char[] cbuf) throws IOException,
która powinna zapisywać dane zarówno do fileWriter jak i do konsoli.
8. Klasa FileConsoleWriter musi posiadać metodę close() throws IOException,
która powinna wywoływać odpowiednią metodę w fileWriter.
*/