Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level19.lesson10.bonus02;
- /* Свой FileWriter
- Реализовать логику FileConsoleWriter
- Должен наследоваться от FileWriter
- При записи данных в файл, должен дублировать эти данные на консоль
- */
- import java.io.File;
- import java.io.FileDescriptor;
- import java.io.FileWriter;
- import java.io.IOException;
- public class FileConsoleWriter extends FileWriter
- {
- public FileConsoleWriter(String fileName) throws IOException
- {
- super(fileName);
- }
- public FileConsoleWriter(String fileName, boolean append) throws IOException
- {
- super(fileName, append);
- }
- public FileConsoleWriter(File file) throws IOException
- {
- super(file);
- }
- public FileConsoleWriter(File file, boolean append) throws IOException
- {
- super(file, append);
- }
- public FileConsoleWriter(FileDescriptor fd)
- {
- super(fd);
- }
- /*----------------------------------------------------------*/
- /*1*/
- public void write(int c) throws IOException {
- System.out.print(Character.toString ((char) c));
- super.write(c);
- }
- /*2*/
- public void write(char cbuf[], int off, int len) throws IOException {
- System.out.print(new String(cbuf,off,len));
- super.write(cbuf, off, len);
- }
- /*3*/
- public void write(String str, int off, int len) throws IOException {
- System.out.print(str.substring(off,len));
- super.write(str, off, len);
- }
- /*---------------------------------------------------------*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement