Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level19.lesson03.task02;
- /* Адаптер
- Используйте класс AdapterFileOutputStream,
- чтобы адаптировать FileOutputStream к новому интерфейсу AmigoStringWriter
- */
- /*
- * Реализовать функции
- * 1. flush() throws IOException
- * 2. writeString(String s) throws IOException
- * 3. close() throws IOException
- * */
- import java.io.FileOutputStream;
- import java.io.IOException;
- public class AdapterFileOutputStream implements AmigoStringWriter{
- private FileOutputStream fileOutputStream;
- AdapterFileOutputStream (FileOutputStream fileOutputStream) {
- this.fileOutputStream = fileOutputStream;
- }
- @Override
- public void flush() throws IOException
- {
- fileOutputStream.flush();
- }
- @Override
- public void writeString(String s) throws IOException
- {
- fileOutputStream.write(s.getBytes());
- }
- @Override
- public void close() throws IOException
- {
- fileOutputStream.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement