当前位置: 首页>>代码示例>>Java>>正文


Java InflaterOutputStream.write方法代码示例

本文整理汇总了Java中java.util.zip.InflaterOutputStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java InflaterOutputStream.write方法的具体用法?Java InflaterOutputStream.write怎么用?Java InflaterOutputStream.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.InflaterOutputStream的用法示例。


在下文中一共展示了InflaterOutputStream.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decompressData

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
public static String decompressData(String encdata) {
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InflaterOutputStream zos = new InflaterOutputStream(bos);
        zos.write(getdeBASE64inCodec(encdata));
        zos.close();
        return new String(bos.toByteArray());
    } catch (Exception ex) {
        ex.printStackTrace();
        return "UNZIP_ERR";
    }
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:13,代码来源:DigestUtils.java

示例2: inflate

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
private String inflate(byte[] decodedBytes) throws IOException {
    ByteArrayOutputStream inflatedBytes = new ByteArrayOutputStream();
    Inflater inflater = new Inflater(true);
    InflaterOutputStream inflaterStream = new InflaterOutputStream(inflatedBytes, inflater);
    inflaterStream.write(decodedBytes);
    inflaterStream.finish();
    return new String(inflatedBytes.toByteArray());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:9,代码来源:SAMLResponseExtractor.java

示例3: decompressData

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
public static byte[] decompressData(String encdata) throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    InflaterOutputStream zos = new InflaterOutputStream(bos);
    byte[] bs = decryptBASE64(encdata);
    zos.write(bs);
    zos.close();
    return bos.toByteArray();
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:9,代码来源:CryptUtil.java

示例4: deserialize

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
public static TileMap deserialize(JSONObject object) {

        TileMap tileMap = new TileMap(World.WORLD_SIZE, World.WORLD_SIZE);

        byte[] compressedBytes = Base64.getDecoder().decode((String) object.get("z"));

        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Inflater decompressor = new Inflater(true);
            InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(baos, decompressor);
            inflaterOutputStream.write(compressedBytes);
            inflaterOutputStream.close();

            byte[] terrain = baos.toByteArray();

            for (int x = 0; x < World.WORLD_SIZE; x++) {
                for (int y = 0; y < World.WORLD_SIZE; y++) {
                    tileMap.tiles[x][y] = terrain[x * World.WORLD_SIZE + y];
                }
            }

            return tileMap;


        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:31,代码来源:TileMap.java

示例5: deserialize

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
public static Memory deserialize(DBObject obj) {

        Memory memory = new Memory(0);

        String zipBytesStr = (String) obj.get("zipBytes");

        if (zipBytesStr != null) {
            byte[] compressedBytes = Base64.getDecoder().decode((String) obj.get("zipBytes"));

            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                Inflater decompressor = new Inflater(true);
                InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(baos, decompressor);
                inflaterOutputStream.write(compressedBytes);
                inflaterOutputStream.close();

                memory.setBytes(baos.toByteArray());

            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            LogManager.LOGGER.severe("Memory was manually deleted");
            memory = new Memory(GameServer.INSTANCE.getConfig().getInt("memory_size"));
        }

        return memory;
    }
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:29,代码来源:Memory.java

示例6: zlib_decompress

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
public static byte[] zlib_decompress(byte[] encdata,int offset) {
 try {
   ByteArrayOutputStream out = new ByteArrayOutputStream(); 
   InflaterOutputStream inf = new InflaterOutputStream(out); 
   inf.write(encdata,offset, encdata.length-offset); 
   inf.close(); 
   return out.toByteArray(); 
  } catch (Exception ex) {
  	ex.printStackTrace(); 
  	return "ERR".getBytes(); 
  }
}
 
开发者ID:KnIfER,项目名称:mdict-parser-java,代码行数:13,代码来源:mdictRes.java

示例7: zlib_decompress_to_str

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
public static String zlib_decompress_to_str(byte[] encdata,int offset) {
 try {
   ByteArrayOutputStream out = new ByteArrayOutputStream(); 
   InflaterOutputStream inf = new InflaterOutputStream(out); 
   inf.write(encdata,offset, encdata.length-offset); 
   inf.close(); 
   return out.toString("ASCII");
  } catch (Exception ex) {
  	ex.printStackTrace(); 
  	return "ERR"; 
  }
}
 
开发者ID:KnIfER,项目名称:mdict-parser-java,代码行数:13,代码来源:mdict.java

示例8: receiveCompressedMessage

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
private JsonNode receiveCompressedMessage() throws IOException {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    final InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(bos);

    inflaterOutputStream.write(server.getReceivedData());
    inflaterOutputStream.close();

    return new ObjectMapper().readTree(bos.toByteArray());
}
 
开发者ID:osiegmar,项目名称:logback-gelf,代码行数:10,代码来源:GelfUdpAppenderTest.java

示例9: inflate

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
private Object[] inflate(byte[] data) throws LuaException {
	if (data.length >= Config.APIs.Data.limit) throw new LuaException("Data is too long");

	ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
	InflaterOutputStream inos = new InflaterOutputStream(baos, new Inflater(true));
	try {
		inos.write(data);
		inos.finish();
	} catch (IOException e) {
		throw LuaHelpers.rewriteException(e, "Inflating error");
	}

	return new Object[]{baos.toByteArray()};
}
 
开发者ID:SquidDev-CC,项目名称:CCTweaks-Lua,代码行数:15,代码来源:DataAPI.java

示例10: readCompressedData

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
protected void readCompressedData(byte[] readData) throws IOException {
    if (readData.length == originalLength) {
        this.tableData = readData;
        return;
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    InflaterOutputStream compressStream = new InflaterOutputStream(out);
    compressStream.write(readData);
    compressStream.close();

    tableData = out.toByteArray();
}
 
开发者ID:m-abboud,项目名称:FontVerter,代码行数:14,代码来源:Woff1Font.java

示例11: gunzipBytes

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
public static byte[] gunzipBytes(byte[] compressedBytes) throws IOException
{
    ByteArrayOutputStream bos = new ByteArrayOutputStream((int)(compressedBytes.length * 1.5));
    InflaterOutputStream dos = new InflaterOutputStream(bos);
    dos.write(compressedBytes);
    dos.close();
    return bos.toByteArray();
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:9,代码来源:CompressionService.java

示例12: test_write_I

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.util.zip.InflaterOutputStream#write(int)
 */
public void test_write_I() throws IOException {
    int length = compressToBytes(testString);

    // uncompress the data stored in the compressedBytes
    InflaterOutputStream ios = new InflaterOutputStream(os);
    for (int i = 0; i < length; i++) {
        ios.write(compressedBytes[i]);
    }

    String result = new String(os.toByteArray());
    assertEquals(testString, result);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:InflaterOutputStreamTest.java

示例13: test_write_I_Illegal

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.util.zip.InflaterOutputStream#write(int)
 */
public void test_write_I_Illegal() throws IOException {

    // write after close
    InflaterOutputStream ios = new InflaterOutputStream(os);
    ios.close();
    try {
        ios.write(-1);
        fail("Should throw IOException");
    } catch (IOException e) {
        // expected
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:InflaterOutputStreamTest.java

示例14: compressToBytes

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.util.zip.InflaterOutputStream#write(byte[],int,int)
 */
public void test_write_$BII() throws IOException {
    int length = compressToBytes(testString);

    // uncompress the data stored in the compressedBytes
    InflaterOutputStream ios = new InflaterOutputStream(os);
    ios.write(compressedBytes, 0, length);

    String result = new String(os.toByteArray());
    assertEquals(testString, result);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:14,代码来源:InflaterOutputStreamTest.java

示例15: decompress

import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
@Override
public byte[] decompress(final byte[] data) {
  if (data == null) {
    return null;
  }

  final ByteArrayOutputStream buffer = new ByteArrayOutputStream(data.length);
  final InflaterOutputStream inflaterStream = new InflaterOutputStream(buffer, new Inflater());

  try {
    inflaterStream.write(data);
    inflaterStream.close();
    buffer.close();
  } catch (final IOException e) {
    throw new RuntimeException("failed compressing using deflate", e);
  }

  return buffer.toByteArray();
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:20,代码来源:DeflateCompressor.java


注:本文中的java.util.zip.InflaterOutputStream.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。