0 Replies Latest reply on Sep 23, 2008 3:04 PM by Ahmet temiz

    error: Bad file descriptor

    Ahmet temiz Novice

      hello

      I found this example from net and tried :

      <a4j:mediaOutput id="telephone" element="img" cacheable="false" session="true"
      mimeType="image/png"
      createContent="#{imagePainter.drawImage}" >
      </a4j:mediaOutput>


      and backing bean

      package net.javabeat.articles.ajax4jsf.introduction;

      import java.io.*;

      public class ImagePainter {

      private String fileName = "dkonak_toygar.png";

      public void drawImage(OutputStream output, Object object)
      throws IOException {

      System.out.println("doÄŸa");

      File file = new File(fileName);

      byte byteArray[] = new byte[1000];


      FileInputStream inputStream = new FileInputStream(file);
      while (true) {
      try {
      System.out.println(file.getAbsoluteFile());
      int bytesRead = inputStream.read(byteArray);
      output.write(byteArray, 0, bytesRead);
      } finally {
      if (inputStream != null) {
      inputStream.close();
      }
      }
      }
      }
      }

      But I always got this message although I checked the image file and the java bean.

      java.io.IOException: Bad file descriptor

      what can I do ?

      regards