List of usage examples for org.apache.commons.compress.compressors.deflate DeflateCompressorInputStream DeflateCompressorInputStream
public DeflateCompressorInputStream(final InputStream inputStream)
From source file:net.cloudkit.enterprises.ws.SuperPassParaProxyTest.java
public static void main(String[] args) throws Exception { // CodeLists_Const???XML? // MFT2008? RMFT8ChangeReasonCode (AlphaNumber) // 001 ?/*from w w w . j a va 2 s. c o m*/ // 002 // 003 ? // 004 ???? // 005 ???? // 006 ?????? // 007 ???? // 008 ???? // 009 ?????? // 010 ???? // 011 ??? // 012 ? // 013 ? // 014 ? // 015 ?? // 999 // // MFT2008 RMFT8DeclareTypeCode (AlphaNumber) // MT1401 ?? // MT2401 ??? // MT5401 ?? // MT5402 ?? // MT3402 ? // MT7402 ?? // MT8401 ?? // MT8402 ?? // MT8403 ??? // MT8404 ??? // MT4401 ?? // MT4402 ?? // MT4403 ?? // MT4404 ?? // MT4405 ?? // MT4406 ?? // // MFT2008 RMFT8DeclareTypeCodeStat (AlphaNumber) // MT1401 ?? // MT2401 ??? // MT5401 ?? // MT5402 ?? // MT3402 ? // MT7402 ?? // MT8401 ?? // MT8402 ?? // MT8403 ??? // MT8404 ??? // MT4401 ?? // MT4402 ?? // MT4403 ?? // MT4404 ?? // MT4405 ?? // MT4406 ?? // // MFT2008 RMFT8FunctionTypeCode (AlphaNumber) // 2 // 3 // T // 5 ? // 9 ??? // 0 ??? // 11 // // MFT2008 (AlphaNumber) RMFT8ReponseTypeCode // M1 M1- // M2 M2-?? // M3 QP // 01 01-? // 02 02- // 03 03-? // 11 11- // 12 12- // 13 13-?? // T T- // D D-? // E1 E1-?? // E2 E2-? // E3 E3-?? // E4 E4-? // // ? (AlphaNumber) MasterAffirmSign // 0 // 1 ? // 2 ? // // ? ? (AlphaNumber) DeclareType // 0 // 1 // // MFT2008?? RMFT8MobileTypeCode (AlphaNumber) // MT4403 ?? // MT4404 ?? // MT4405 ?? // MT4406 ?? // // ? RMFT8MobileFuncCode (AlphaNumber) // M1 // M2 ?? // M3 QP // 2 // 3 // T // 5 ? // 9 ? // 0 (??) // 11 URL url = new URL("http://ceesb.chinaport.gov.cn/SuperPassParaProxy/Proxy_Services/SuperPass_Proxy?wsdl"); QName qname = new QName("http://www.cneport.com/webservices/superpass", "SuperPass"); Service service = Service.create(url, qname); SuperPass superPass = service.getPort(SuperPass.class); /* String serviceName = "eport.superpass.pub.para.CustomsFlagStatus"; byte[] requestContext = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><RequestContext><Group name=\"SystemInfo\"><Key name=\"ClientId\">5300001128334</Key><Key name=\"CertNo\">c1f4bb</Key><Key name=\"SaicSysNo\">618882068</Key><Key name=\"DEP_IN_CODE\">5300</Key><Key name=\"REG_CO_CGAC\">4403941436</Key><Key name=\"ENT_SEQ_NO\">000000000000063462</Key><Key name=\"IcCode\">8800000246746</Key><Key name=\"OperatorName\"></Key><Key name=\"DEP_CODE_CHG\">5300</Key><Key name=\"NAME_FULL\">???</Key></Group><Group name=\"DataPresentation\"><Key name=\"SignatureAlgorithm\" /><Key name=\"EncryptAlgorithm\" /><Key name=\"CompressAlgorithm\" /></Group></RequestContext>".getBytes(); byte[] requestData = "<?xml version=\"1.0\"?>\n<CustomsFlagStatusRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<CustomsCode>5300</CustomsCode>\n</CustomsFlagStatusRequest>".getBytes(); */ // ?? String serviceName = "eport.superpass.pub.para.LoadIntoMemory"; byte[] requestContext = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><RequestContext><Group name=\"SystemInfo\"><Key name=\"ClientId\">5300001128334</Key><Key name=\"CertNo\">b6c29b</Key><Key name=\"SaicSysNo\">618882068</Key><Key name=\"DEP_IN_CODE\">5300</Key><Key name=\"REG_CO_CGAC\">4403941436</Key><Key name=\"ENT_SEQ_NO\">000000000000063462</Key><Key name=\"SessionId\">2015-7-14</Key><Key name=\"IcCode\">8910000270086</Key><Key name=\"OperatorName\">??</Key><Key name=\"DEP_CODE_CHG\">5300</Key><Key name=\"NAME_FULL\">???</Key></Group><Group name=\"DataPresentation\"><Key name=\"SignatureAlgorithm\" /><Key name=\"EncryptAlgorithm\" /><Key name=\"CompressAlgorithm\" /></Group></RequestContext>" .getBytes(); // ? MFT8TrayType // SELECT TRAY_CODE,TRAY_NAME FROM MFT8_TRAY_TYPE ORDER BY TRAY_CODE // ??? RMFT8TransportType // SELECT CODE, NAME FROM mft8_transport_type ORDER BY CODE // ? RMFT8CustomsCode // SELECT customs_CODE, customs_NAME FROM customs ORDER BY customs_CODE // ??(CN003) RMFT8PortCode // SELECT CODE, CHNAME FROM mft8_location_name ORDER BY CODE // ? RMFT8Curr // SELECT CODE, NAME FROM MFT8_ROAD_CURR ORDER BY CODE // ? RMFT8ReceiptPlace // SELECT CODE, NAME FROM mft8_entity ORDER BY CODE // ? RMFT8CountryCode // SELECT CODE, NAME FROM mft8_country_code ORDER BY CODE // ?? RMFT8CustomStatus // SELECT CODE, NAME FROM MFT8_ROAD_CUSTOMS_STATUS ORDER BY CODE // ?? RMFT8TransPayCode // SELECT CODE, NAME FROM MFT8_ROAD_PAYMENT_METHOD ORDER BY CODE // ??(CN005) RMFT8WrapTypeCode // SELECT CODE, NAME FROM mft8_packaging ORDER BY CODE // ??? RMFT8TransLicCode // SELECT CODE, NAME FROM MFT8_CONTR_CAR_COND ORDER BY CODE // ?? RMFT8PortWorkCode // SELECT CODE, NAME FROM MFT8_HAND_INSTR ORDER BY CODE // ?? RMFT8CommunicationCode // SELECT CODE, NAME FROM mft8_communi_type ORDER BY CODE // ? RMFT8PostCode // SELECT CODE, NAME FROM mft8_post_code ORDER BY CODE // RMFT8EquipSizeCode // SELECT CODE, SHAPE,LENGTH,HEIGHT,WIDTH FROM mft8_equip_size_type ORDER BY CODE // ??? RMFT8EquipSupCode // SELECT CODE, NAME FROM MFT8_EQUIP_SUP ORDER BY CODE // ?? RMFT8EquipFullCode // SELECT CODE, NAME FROM mft8_equip_full ORDER BY CODE // ?? RMFT8EquipSealCode // SELECT CODE, NAME FROM mft8_seal_agency ORDER BY CODE // ??? RMFT8DanGoodsCode // SELECT CODE, CHNAME FROM mft8_dan_goods ORDER BY CODE // ? RMFT8CusProCode // SELECT CODE, NAME FROM mft8_cus_procedure ORDER BY CODE // ?/? RMFT8TransportSplitCode // SELECT CODE, NAME FROM mft8_indication ORDER BY CODE // ?? RMFT8DamageAreaCode // SELECT CODE, NAME FROM MFT8_DAMAGE_AREA ORDER BY CODE // ?? RMFT8DamageTypeCode // SELECT CODE, NAME FROM MFT8_DAMAGE_TYPE_DES ORDER BY CODE // IATA?(UN005) RMFT8IATACode // SELECT CODE, NAME FROM mft8_iata_code ORDER BY CODE // ????(UN009) RMFT8LocodePort // SELECT CODE, NAME FROM mft8_un_locode_port ORDER BY CODE // RMFT8ComplexCode // SELECT CODE_TS, G_NAME FROM complex ORDER BY CODE_TS byte[] requestData = "<?xml version=\"1.0\"?>\n<LoadIntoMemoryRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<QuerySql>SELECT CODE, NAME FROM mft8_un_locode_port ORDER BY CODE</QuerySql>\n</LoadIntoMemoryRequest>" .getBytes(); Holder<byte[]> responseData = new Holder<byte[]>(); System.out.println(new String(superPass.service(serviceName, requestContext, requestData, responseData))); // deflate DeflateCompressorInputStream gis = new DeflateCompressorInputStream( new ByteArrayInputStream(responseData.value)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int count; byte data[] = new byte[1024]; while ((count = gis.read(data, 0, 1024)) != -1) { baos.write(data, 0, count); } gis.close(); data = baos.toByteArray(); baos.flush(); baos.close(); System.out.println(new String(data)); // System.out.println(new String(responseData.value, "UTF-8")); }
From source file:com.spotify.echoprintserver.nativelib.Util.java
/** * Decode an Echoprint string into its list of codes (temporal offsets are not returned). *//*from w ww. ja v a2 s .c o m*/ public static List<Integer> decodeEchoprintString(String echoprintString) throws IOException { byte[] decoded = b64SafeDecode(echoprintString); DeflateCompressorInputStream is = new DeflateCompressorInputStream(new ByteArrayInputStream(decoded)); ByteArrayOutputStream os = new ByteArrayOutputStream(); IOUtils.copy(is, os); String decodedEchoprintString = os.toString(); // skip the first half of the string (offsets) // take every 5 chars, parse int in base 16 List<Integer> codes = new ArrayList<Integer>(); int N = decodedEchoprintString.length(); for (int n = N / 2; n < N; n += 5) { String s = decodedEchoprintString.substring(n, n + 5); Integer c = Integer.parseInt(s, 16); codes.add(c); } return codes; }
From source file:gzipper.algorithms.Zip.java
@Override protected void extract(String path, String name) throws IOException { try (ZipArchiveInputStream zis = new ZipArchiveInputStream( new DeflateCompressorInputStream(new BufferedInputStream(new FileInputStream(path + name))))) { ArchiveEntry entry = zis.getNextEntry(); /*create main folder of gzip archive*/ File folder = new File(Settings._outputPath + name.substring(0, 7)); if (!folder.exists()) { folder.mkdir();//from w ww.j av a 2 s . co m } while (entry != null & _runFlag) { String entryName = entry.getName(); /*check if entry contains a directory*/ if (entryName.contains("/")) { File newFile; if (Settings._isUnix) { //check OS for correct file path newFile = new File(folder.getAbsolutePath() + "/" + entryName); } else { newFile = new File(folder.getAbsolutePath() + "\\" + entryName); } /*mkdirs also creates parent directories*/ if (!newFile.getParentFile().exists()) { newFile.getParentFile().mkdirs(); } } String newFilePath; if (Settings._isUnix) { //check OS for correct file path newFilePath = folder.getAbsolutePath() + "/" + entryName; } else { newFilePath = folder.getAbsolutePath() + "\\" + entryName; } /*create new OutputStream and write bytes to file*/ try (BufferedOutputStream buf = new BufferedOutputStream(new FileOutputStream(newFilePath))) { byte[] buffer = new byte[4096]; int readBytes; while ((readBytes = zis.read(buffer)) != -1) { buf.write(buffer, 0, readBytes); } } entry = zis.getNextEntry(); } } }
From source file:org.apache.beam.sdk.io.FileBasedSinkTest.java
/** {@link CompressionType#DEFLATE} correctly writes deflate data. */ @Test/*from w w w. j ava 2 s .com*/ public void testCompressionTypeDEFLATE() throws FileNotFoundException, IOException { final File file = writeValuesWithWritableByteChannelFactory(CompressionType.DEFLATE, "abc", "123"); // Read Gzipped data back in using standard API. assertReadValues(new BufferedReader(new InputStreamReader( new DeflateCompressorInputStream(new FileInputStream(file)), StandardCharsets.UTF_8.name())), "abc", "123"); }
From source file:org.apache.tika.parser.pkg.TikaCompressorStreamFactory.java
public CompressorInputStream createCompressorInputStream(final String name, final InputStream in, final boolean actualDecompressConcatenated) throws CompressorException { if (name == null || in == null) { throw new IllegalArgumentException("Compressor name and stream must not be null."); }//w ww . java2 s . c o m try { if (GZIP.equalsIgnoreCase(name)) { return new GzipCompressorInputStream(in, actualDecompressConcatenated); } if (BZIP2.equalsIgnoreCase(name)) { return new BZip2CompressorInputStream(in, actualDecompressConcatenated); } if (XZ.equalsIgnoreCase(name)) { if (!XZUtils.isXZCompressionAvailable()) { throw new CompressorException("XZ compression is not available."); } return new XZCompressorInputStream(in, actualDecompressConcatenated); } if (LZMA.equalsIgnoreCase(name)) { if (!LZMAUtils.isLZMACompressionAvailable()) { throw new CompressorException("LZMA compression is not available"); } try { return new SaferLZMACompressorInputStream(in); } catch (MemoryLimitException e) { throw new CompressorException("MemoryLimitException: " + e.getMessage(), e); } } if (PACK200.equalsIgnoreCase(name)) { return new Pack200CompressorInputStream(in); } if (SNAPPY_RAW.equalsIgnoreCase(name)) { return new SnappyCompressorInputStream(in); } if (SNAPPY_FRAMED.equalsIgnoreCase(name)) { return new FramedSnappyCompressorInputStream(in); } if (Z.equalsIgnoreCase(name)) { try { return new SaferZCompressorInputStream(in); } catch (TikaRuntimeMemoryLimitException e) { throw new CompressorException("MemoryLimitException: " + e.getMessage(), e); } } if (DEFLATE.equalsIgnoreCase(name)) { return new DeflateCompressorInputStream(in); } /* not currently supported if (LZ4_BLOCK.equalsIgnoreCase(name)) { return new BlockLZ4CompressorInputStream(in); } if (LZ4_FRAMED.equalsIgnoreCase(name)) { return new FramedLZ4CompressorInputStream(in, actualDecompressConcatenated); } */ } catch (final IOException e) { throw new CompressorException("Could not create CompressorInputStream.", e); } final CompressorStreamProvider compressorStreamProvider = getCompressorInputStreamProviders() .get(toKey(name)); if (compressorStreamProvider != null) { return compressorStreamProvider.createCompressorInputStream(name, in, actualDecompressConcatenated); } throw new CompressorException("Compressor: " + name + " not found."); }