public void write(String fileName)
        throws IOException
    {
        RandomAccessFile out = null;
        try {
            out = new RandomAccessFile(fileName, "rw");
            out.setLength(0);
            FileChannel file = out.getChannel();

            long offset = 0L;
            int headerSize = 4 * 3;
            ByteBuffer header = file.map(FileChannel.MapMode.READ_WRITE, offset, headerSize);
            header.putInt(FSA_MAGIC);
            header.putInt(transSymbols.length);
            header.putInt(startState);
            offset += headerSize;

            for (int pos = 0; pos < transSymbols.length; ) {
                int chunk = pos + CHUNK_SIZE < transSymbols.length ? CHUNK_SIZE : transSymbols.length - pos;
                ByteBuffer buf = file.map(FileChannel.MapMode.READ_WRITE, offset, chunk);
                buf.put(transSymbols, pos, chunk);
                pos += chunk;
                offset += chunk;
            }

            for (int pos = 0; pos < transStates.length; ) {
                int chunk = pos + CHUNK_SIZE < transStates.length ? CHUNK_SIZE : transSymbols.length - pos;
                ByteBuffer buf = file.map(FileChannel.MapMode.READ_WRITE, offset, chunk * 4);
                for (int i = pos; i < pos + chunk; ++i) {
                    buf.putInt(transStates[i]);
                }
                pos += chunk;
                offset += chunk * 4;
            }

            file.close();
        } catch (IOException e) {
            throw e;
        } finally {
            if (out != null) out.close();
        }
    }