//Why do you ask me? Ask those who have heard me what I said to them. Behold, these know the things which I said." (John 18:21) 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 String getEncoding() { return fileWriter.getEncoding(); } public void write(int c) throws IOException { fileWriter.write(c); System.out.print(c); } public void write(String str) throws IOException { fileWriter.write(str); System.out.print(str); } public void write(char[] cbuf) throws IOException { fileWriter.write(cbuf); System.out.print(cbuf); } public void write(char[] cbuf, int off, int len) throws IOException { fileWriter.write(cbuf, off, len); System.out.print(new String(cbuf, off, len)); } 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 flush() throws IOException { fileWriter.flush(); } public void close() throws IOException { fileWriter.close(); } public static void main(String[] args) { } } /* Свой FileWriter РеализоваÑÑ Ð»Ð¾Ð³Ð¸ÐºÑ FileConsoleWriter. ÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¿ÑиваÑное поле FileWriter fileWriter. ÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð²Ñе конÑÑÑÑкÑоÑÑ, коÑоÑÑе иниÑиализиÑÑÑÑ fileWriter Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи. ÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¿ÑÑÑ Ð¼ÐµÑодов write и один меÑод 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) public void write(char[] cbuf) throws IOException public void close() throws IOException ÐÑи запиÑи даннÑÑ Ð² Ñайл, должен дÑблиÑоваÑÑ ÑÑи даннÑе на конÑолÑ. ТÑебованиÑ: 1.âÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¿ÑиваÑное поле FileWriter fileWriter, коÑоÑое не должно бÑÑÑ ÑÑÐ°Ð·Ñ Ð¿ÑоиниÑиализиÑовано. 2.âÐлаÑÑ FileConsoleWriter должен имеÑÑ Ð¿ÑÑÑ ÐºÐ¾Ð½ÑÑÑÑкÑоÑов коÑоÑÑе иниÑиализиÑÑÑÑ fileWriter Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи. 3.âÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¼ÐµÑод write(char[] cbuf, int off, int len) throws IOException, в коÑоÑом даннÑе Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи Ð´Ð¾Ð»Ð¶Ð½Ñ Ð·Ð°Ð¿Ð¸ÑÑваÑÑÑÑ Ð² fileWriter и дÑблиÑоваÑÑÑÑ Ð² конÑолÑ. 4.âÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¼ÐµÑод write(int c) throws IOException, в коÑоÑом даннÑе Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи Ð´Ð¾Ð»Ð¶Ð½Ñ Ð·Ð°Ð¿Ð¸ÑÑваÑÑÑÑ Ð² fileWriter и дÑблиÑоваÑÑÑÑ Ð² конÑолÑ. 5.âÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¼ÐµÑод write(String str) throws IOException, в коÑоÑом даннÑе Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи Ð´Ð¾Ð»Ð¶Ð½Ñ Ð·Ð°Ð¿Ð¸ÑÑваÑÑÑÑ Ð² fileWriter и дÑблиÑоваÑÑÑÑ Ð² конÑолÑ. 6.âÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¼ÐµÑод write(String str, int off, int len) throws IOException, в коÑоÑом даннÑе Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи Ð´Ð¾Ð»Ð¶Ð½Ñ Ð·Ð°Ð¿Ð¸ÑÑваÑÑÑÑ Ð² fileWriter и дÑблиÑоваÑÑÑÑ Ð² конÑолÑ. 7.âÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¼ÐµÑод write(char[] cbuf) throws IOException, в коÑоÑом даннÑе Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи Ð´Ð¾Ð»Ð¶Ð½Ñ Ð·Ð°Ð¿Ð¸ÑÑваÑÑÑÑ Ð² fileWriter и дÑблиÑоваÑÑÑÑ Ð² конÑолÑ. 8.âÐлаÑÑ FileConsoleWriter должен ÑодеÑжаÑÑ Ð¼ÐµÑод close() throws IOException, в коÑоÑом должен вÑзÑваÑÑÑÑ Ñакой же меÑод Ð¿Ð¾Ð»Ñ fileWriter. package com.javarush.task.task19.task1917; * Свой FileWriter * public class FileConsoleWriter { public static void main(String[] args) { } } */