?
package com.javarush.task.task19.task1917;
/*
Свой FileWriter
*/
import java.io.*;
public class FileConsoleWriter {
private FileWriter fileWriter;
public FileConsoleWriter(FileWriter fileWriter) throws IOException {
this.fileWriter = fileWriter;
}
public void write(int c) throws IOException {
fileWriter.write(c);
System.out.print((char) c);
}
public void write(char[] cbuf, int off, int len) throws IOException {
for(int i = 0; i<len; i++) {
fileWriter.write(cbuf[off+i]);
System.out.print(cbuf[off+i]);
}
}
public void write(String str, int off, int len) throws IOException {
fileWriter.write(str, off, len);
System.out.print(str.substring(off, off+len));
}
public void close() throws IOException {
fileWriter.close();
}
public void write(char[] cbuf) throws IOException {
fileWriter.write(cbuf);
System.out.print(cbuf);
}
public void write(String str) throws IOException {
fileWriter.write(str);
System.out.print(str);
}
public static void main(String[] args) throws IOException {
FileConsoleWriter fc = new FileConsoleWriter(new FileWriter("C:/Users/Zar_ponosa/Desktop/1.txt"));
fc.write("aaabbbccc".toCharArray(),3,3);
}
}