While trying to import XLS files from Flex front-end, we needed to pass the file contents to Java middle tier, where Apache POI library was used to parse the contents. The Java method expects a Java ByteArray containing the file contents, but when we pass a Flex ByteArray to it, it throws error. To overcome this instead of passing Flex ByteArray, we should pass an Array of bytes, as depicted in following code snippet: public static function byteArrayToArrayOfBytes(ba:ByteArray):Array { var arrayOfBytes:Array = []; ba.position = 0; while(ba.bytesAvailable > 0) arrayOfBytes.push(ba.readByte()); ba.position = 0; return arrayOfBytes; } public function onFileSelectionComplete(fileReference:FileReference) { var payload:Object = new Object(); payload.byteArray = byteArrayToArrayOfBytes(fileReference.data); ExternalInterface.call("parseXLS", payload); }