Seems like all conditions are met, but solution does not validate
package com.codegym.task.task19.task1917;
/*
Your own FileWriter
*/
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileWriter;
import java.io.IOException;
public class FileConsoleWriter{
private FileWriter fileWriter;
private FileWriter consoleWriter;
public FileConsoleWriter(File file) throws IOException {
fileWriter = new FileWriter(file);
}
public FileConsoleWriter(File file, boolean append) throws IOException {
fileWriter = new FileWriter(file,append);
consoleWriter = new FileWriter(FileDescriptor.out);
}
public FileConsoleWriter(FileDescriptor fd) {
fileWriter = new FileWriter(fd);
consoleWriter = new FileWriter(FileDescriptor.out);
}
public FileConsoleWriter(String fileName) throws IOException {
fileWriter = new FileWriter(fileName);
consoleWriter = new FileWriter(FileDescriptor.out);
}
public FileConsoleWriter(String fileName, boolean append) throws IOException {
fileWriter = new FileWriter(fileName,append);
consoleWriter = new FileWriter(FileDescriptor.out);
}
public void write(char[] cbuf, int off, int len) throws IOException {
fileWriter.write(cbuf,off,len);
consoleWriter.write(cbuf,off,len);
fileWriter.flush();
consoleWriter.flush();
}
public void write(int c) throws IOException {
fileWriter.write(c);
consoleWriter.write(c);
fileWriter.flush();
consoleWriter.flush();
}
public void write(String str) throws IOException {
fileWriter.write(str);
consoleWriter.write(str);
fileWriter.flush();
consoleWriter.flush();
}
public void write(String str, int off, int len) throws IOException {
fileWriter.write(str,off,len);
consoleWriter.write(str,off,len);
fileWriter.flush();
consoleWriter.flush();
}
public void write(char[] cbuf) throws IOException {
fileWriter.write(cbuf);
consoleWriter.write(cbuf);
fileWriter.flush();
consoleWriter.flush();
}
public void close() throws IOException {
fileWriter.close();
consoleWriter.close();
}
public static void main(String[] args) throws IOException {
FileConsoleWriter fw = new FileConsoleWriter("test.txt");
String str = "hello world";
char[] ch = new char[str.length()];
for (int i = 0; i < str.length(); i++) {
ch[i] = str.charAt(i);
}
fw.write(50);
}
}