We are processing a byte[] as shown below (the file is POST'ed to a web server, this code is running in Glassfish) and have found that some files have a byte-order mark (BOM, a three-byte sequence 0xEF,0xBB,0xBF, see: <http://en.wikipedia.org/wiki/Byte_order_mark>) at the beginning, and we want to remove this BOM. How would we detect and remove a BOM in this code? Thanks.

```
  private final void serializePayloadToFile(File file, byte[] payload) throws IOException {

    FileOutputStream fos;
    DataOutputStream dos;

    fos = new FileOutputStream(file, true); // true for append
    dos = new DataOutputStream(fos);

    dos.write(payload);
    dos.flush();
    dos.close();
    fos.close();

    return;
  }  

```