Убедись, что метод write(char[] cbuf, int off, int len) throws IOException класса FileConsoleWriter дублирует данные в консоль.
Убедись, что метод write(String str, int off, int len) throws IOException класса FileConsoleWriter вызывает такой же метод в fileWriter.
package com.javarush.task.task19.task1917;
/*
Свой FileWriter
*/
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileWriter;
import java.io.IOException;
public class FileConsoleWriter {
private FileWriter fileWriter;
public FileConsoleWriter(String fileName) throws IOException {
fileWriter = new FileWriter(fileName);
}
public FileConsoleWriter(String fileName, boolean append) throws IOException {
fileWriter = new FileWriter(fileName,append);
}
public FileConsoleWriter(File file) throws IOException {
fileWriter = new FileWriter(file);
}
public FileConsoleWriter(File file, boolean append) throws IOException {
fileWriter = new FileWriter(file,append);
}
public FileConsoleWriter(FileDescriptor fd) {
fileWriter = new FileWriter(fd);
}
public void write(char[] cbuf) throws IOException{
fileWriter.write(cbuf);
System.out.println(cbuf);
}
public void write(int c) throws IOException {
fileWriter.write(c);
System.out.println(c);
}
public void write(char[] cbuf, int off, int len) throws IOException {
fileWriter.write(cbuf, off, len);
char[] chars = cbuf.clone();
for(int i=off; i<len;i++){
System.out.println(chars[i]);
}
}
public void write(String str, int off, int len) throws IOException {
fileWriter.write(str, off, len);
System.out.println(str.substring(off,len));
}
public void write(String str) throws IOException {
fileWriter.write(str);
System.out.println(str);
}
public void close() throws IOException {
fileWriter.close();
}
public static void main(String[] args) {
String s = "123456789 10 11 12";
char[] ccbuf = s.toCharArray();
char[] chars = ccbuf.clone();
int off = 3;
int len = 7;
for(int i=off; i<len+1;i++){
System.out.print(chars[i]);
}
}
}