Advertisement
jaVer404

level19.lesson03.task02

Feb 16th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. package com.javarush.test.level19.lesson03.task02;
  2.  
  3. /* Адаптер
  4. Используйте класс AdapterFileOutputStream,
  5. чтобы адаптировать FileOutputStream к новому интерфейсу AmigoStringWriter
  6. */
  7.  
  8. /*
  9. * Реализовать функции
  10. * 1. flush() throws IOException
  11. * 2. writeString(String s) throws IOException
  12. * 3. close() throws IOException
  13. * */
  14.  
  15. import java.io.FileOutputStream;
  16. import java.io.IOException;
  17.  
  18. public class AdapterFileOutputStream implements AmigoStringWriter{
  19.     private FileOutputStream fileOutputStream;
  20.     AdapterFileOutputStream (FileOutputStream fileOutputStream) {
  21.         this.fileOutputStream = fileOutputStream;
  22.     }
  23.  
  24.     @Override
  25.     public void flush() throws IOException
  26.     {
  27.         fileOutputStream.flush();
  28.     }
  29.  
  30.     @Override
  31.     public void writeString(String s) throws IOException
  32.     {
  33.  
  34.         fileOutputStream.write(s.getBytes());
  35.     }
  36.  
  37.     @Override
  38.     public void close() throws IOException
  39.     {
  40.         fileOutputStream.close();
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement