public void save(String savePath) throws IOException, JPEGParser.InvalidJpegFormatException {
        DataOutputStream fsave = null;
        try {
            fsave = new DataOutputStream(new FileOutputStream(savePath));
            // 写入SOI

            fsave.writeShort(JPEGImage.SOI);
            // 写入APPn
            for ( Map.Entry<Integer, byte[]> appinfo : mApp.entrySet() ){
                fsave.writeShort(appinfo.getKey());
                fsave.writeShort(appinfo.getValue().length+2);
                fsave.write(appinfo.getValue());
            }
            // 写入DQT
            JPEGDQT.saveDQTs(fsave, mDQT);

            // 写入DHT
            for (JPEGHuffman h : mHuffmanDC){
                h.save(fsave);
            }
            for (JPEGHuffman h : mHuffmanAC){
                h.save(fsave);
            }

            // 写入SOF0
            this.saveSOF0(fsave);

            // 写入SOS
            this.saveSOS(fsave);

            // 写入图像数据
            this.saveData(fsave);

            // 写入EOI
            fsave.writeShort(EOI);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            if (fsave != null) {
                try {
                    fsave.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }