title: Java chat application on GAE, trouble with write messages to file
body: <p>I have problem with my program in JSF on Google App Engine platform. I almost finished implement chat application in Java EE, when I read that class <em>FileOutputStream</em> isn't supported by GAE. 
  By this class object I create file, to write inside it chat messages and by scirpt this file is loaded and refreshed on index.xhtml website. </p>
  
  <p>I need help because I don't know which class can I replace <em>FileOutputStream</em> to finish this application. I found <a href="http://vimeo.com/8066901" rel="nofollow">example in Python</a> so I know that this is possible, but how to implement it in Java?</p>
  
  <p>I will be grateful for any help.</p>
  
  <p>Below I paste piece of class ChatBean with <em>FileOutputSream</em> operations: </p>
  
  <pre><code>@Stateful
  @ApplicationScoped
  @ManagedBean(name="Chat")
  public class ChatBean {
  
      private List&lt;String&gt; users = new ArrayList&lt;String&gt;();
      private String newUser;
      FileOutputStream chatHtmlBufferWriter;
  
      public ChatBean () throws IOException {
          ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
          String chatHtmlPath = ctx.getRealPath("/") + "chat";
          try {
              this.chatHtmlBufferWriter = new FileOutputStream(chatHtmlPath);  
              this.chatHtmlBufferWriter.write("Start chatu ąęć. &lt;br /&gt;".getBytes("UTF-8"));
          } catch (IOException ex) {
              this.chatHtmlBufferWriter.close();
              throw ex;
          }
  
          users.add("Admin");
      }
  
      @PreDestroy
      public void closeFileBuffor() throws Exception {
          this.chatHtmlBufferWriter.close();
      }
  
      public String addMessage(String msg) throws IOException {
          this.chatHtmlBufferWriter.write(msg.getBytes("UTF-8"));    
          FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml");
          return "index"; 
      } 
  ...
  }
  </code></pre>
  
  <p>And script inside index.xhtml file: </p>
  
  <pre><code>&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
              &lt;script&gt;
                  var currPos = 0;
                  var loadChat = function() {
                      $("#chatForm\\:chatbox").load('chat');
                      currPos = $(".chat")[0].scrollHeight;
                      $(".chat").scrollTop(currPos);
                  }
                  var scrollChat = function() {
                      $("#chatForm\\:chatbox").load('chat');
                      $(".chat").scrollTop(currPos);
                  }
                  var currPos;
  
                  $(document).ready(function() {
                      $("#chatForm\\:chatbox").load('chat', function(){
                          loadChat();
                      });
                      var refreshId = setInterval(function() {
                          scrollChat();
                      }, 1000);
                      $.ajaxSetup({ cache: false });                    
                      $("#chatForm\\:chatbox").scroll(function() {
                          currPos = $(".chat").scrollTop();
                      });
                  });
              &lt;/script&gt;
  </code></pre>