You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mfaine <mf...@knology.net> on 2005/02/24 18:13:27 UTC

writing a file - difference between browsers?

When I call the uploadAction a file is written to the filesystem of the
server running the application.  When using Firefox it works great but when
I'm using Internet Explorer it crashes out.  Here is the code:

  public void writeFile ( byte[] bytes , String path )
  {
    File file = new File ( path );
    BufferedInputStream bis = new BufferedInputStream ( new
        ByteArrayInputStream ( bytes ) );

    FileOutputStream fis = null;
    try
    {
      fis = new FileOutputStream ( file );
    }
    catch ( FileNotFoundException ex )
    {
      logger.debug ( "File Not Found: " + ex.getMessage () );
      FacesUtils.addErrorMessage ( "Problem writing file to file system. " );
    }
    int length = 0;
    try
    {
      length = bis.available ();
      for ( int x = 0; x < length; x++ )
      {
        fis.write ( bis.read () );//<-- This line is reported as the error.
      }

    }
    catch ( IOException ex1 )
    {
      logger.debug ( "Internal Error: " + ex1.getMessage () );
      FacesUtils.addErrorMessage (
          "Internal Error: Contact System Administrator. " );
    }
    finally
    {
      try
      {
        fis.close ();
        bis.close ();
      }
      catch ( Exception e )
      {

        logger.debug ( "Internal Error: " + e.getMessage () );
        FacesUtils.addErrorMessage ( "Internal Error: Could not close file. " );
      }
    }
  }


Anybody have any idea why one browser works and the other doesn't in writing
this file?

Thanks,
-Mark