Java 类java.util.zip.DataFormatException 实例源码
项目:trashjam2017
文件:PNGDecoder.java
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
try {
do {
int read = inflater.inflate(buffer, offset, length);
if(read <= 0) {
if(inflater.finished()) {
throw new EOFException();
}
if(inflater.needsInput()) {
refillInflater(inflater);
} else {
throw new IOException("Can't inflate " + length + " bytes");
}
} else {
offset += read;
length -= read;
}
} while(length > 0);
} catch (DataFormatException ex) {
throw (IOException)(new IOException("inflate error").initCause(ex));
}
}
项目:HeroVideo-master
文件:BiliDanmukuCompressionTools.java
public static byte[] decompress(byte[] value) throws DataFormatException
{
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
Inflater decompressor = new Inflater();
try
{
decompressor.setInput(value);
final byte[] buf = new byte[1024];
while (!decompressor.finished())
{
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
} finally
{
decompressor.end();
}
return bos.toByteArray();
}
项目:sstable-adaptor
文件:DeflateCompressor.java
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) throws IOException
{
Inflater inf = inflater.get();
inf.reset();
inf.setInput(input, inputOffset, inputLength);
if (inf.needsInput())
return 0;
// We assume output is big enough
try
{
return inf.inflate(output, outputOffset, maxOutputLength);
}
catch (DataFormatException e)
{
throw new IOException(e);
}
}
项目:litiengine
文件:CompressionUtilities.java
public static byte[] decompress(final byte[] data) {
final Inflater inflater = new Inflater();
inflater.setInput(data);
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
final byte[] buffer = new byte[1024];
try {
while (!inflater.finished()) {
int count;
count = inflater.inflate(buffer);
outputStream.write(buffer, 0, count);
}
outputStream.close();
} catch (final DataFormatException | IOException e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
return outputStream.toByteArray();
}
项目:BedrockProxy
文件:BatchPacket.java
@Override
public void decode() {
if (buffer().readableBytes() < 2) return;
try {
setBuffer(Compression.inflate(buffer()));
} catch (DataFormatException e) {
e.printStackTrace();
return;
}
if (buffer().readableBytes() == 0) {
throw new RuntimeException("Decoded BatchPacket payload is empty");
}
buffer().readerIndex(2);
while (buffer().readerIndex() < buffer().readableBytes()) {
PacketRegistry.handlePacket(new RakNetPacket(readBytes()), getPlayer());
}
}
项目:FApkSigner
文件:LocalFileRecord.java
@Override
public void consume(byte[] buf, int offset, int length) throws IOException {
checkNotClosed();
mInflater.setInput(buf, offset, length);
if (mOutputBuffer == null) {
mOutputBuffer = new byte[65536];
}
while (!mInflater.finished()) {
int outputChunkSize;
try {
outputChunkSize = mInflater.inflate(mOutputBuffer);
} catch (DataFormatException e) {
throw new IOException("Failed to inflate data", e);
}
if (outputChunkSize == 0) {
return;
}
mDelegate.consume(mOutputBuffer, 0, outputChunkSize);
mOutputByteCount += outputChunkSize;
}
}
项目:AgentX
文件:CompressWrapper.java
@Override
public byte[] unwrap(byte[] bytes) {
inflater.setInput(bytes);
try {
int len;
byte[] buffer = new byte[bytes.length];
while (!inflater.finished()) {
len = inflater.inflate(buffer, 0, buffer.length);
if (len > 0)
unwrapBuffer.write(buffer, 0, len);
}
return unwrapBuffer.toByteArray();
} catch (DataFormatException e) {
throw new RuntimeException("unknown format: " + e.getMessage());
} finally {
inflater.reset();
unwrapBuffer.reset();
}
}
项目:NotiCap
文件:FilterRule.java
public static JSONObject loadSavedFilterRules(Context context, boolean overwrite) throws IOException, DataFormatException, JSONException {
File file = context.getFileStreamPath("rules");
if (!file.exists())
//noinspection ResultOfMethodCallIgnored
file.createNewFile();
byte[] content = Compressor.readFile(file);
if (!overwrite && content.length > 0) {
String data = new String(Compressor.decompress(content), "UTF-8");
return new JSONObject(data);
} else
return new JSONObject().put("rules", new JSONArray());
}
项目:NotiCap
文件:SSHIdentity.java
public static JSONObject loadSavedIdentities(Context context, boolean overwrite) throws IOException, DataFormatException, JSONException {
File file = context.getFileStreamPath("identities");
if (!file.exists())
//noinspection ResultOfMethodCallIgnored
file.createNewFile();
byte[] content = Compressor.readFile(file);
if (!overwrite && content.length > 0) {
String data = new String(Compressor.decompress(content), "UTF-8");
return new JSONObject(data);
} else
return new JSONObject().put("identities", new JSONArray());
}
项目:NotiCap
文件:SSHIdentity.java
public static SSHIdentity fromID(Context context, long id) throws JSONException, IOException, DataFormatException {
JSONArray savedIdentities = SSHIdentity.loadSavedIdentities(context, false).getJSONArray("identities");
for (int i = 0; i < savedIdentities.length(); i++) {
JSONObject identityObj = savedIdentities.getJSONObject(i);
if (identityObj == null)
continue;
if (identityObj.getLong("id") == id) {
return new SSHIdentity(
identityObj.getString("name"),
identityObj.getString("host"),
identityObj.getString("username"),
identityObj.optString("password"),
identityObj.optString("keyFilePath"),
identityObj.optString("keyFilePassword"),
identityObj.getInt("port"),
identityObj.getLong("id")
);
}
}
return new SSHIdentity();
}
项目:cas-5.1.0
文件:CompressionUtils.java
/**
* Inflate the given byte array by {@link #INFLATED_ARRAY_LENGTH}.
*
* @param bytes the bytes
* @return the array as a string with {@code UTF-8} encoding
*/
public static String inflate(final byte[] bytes) {
final Inflater inflater = new Inflater(true);
final byte[] xmlMessageBytes = new byte[INFLATED_ARRAY_LENGTH];
final byte[] extendedBytes = new byte[bytes.length + 1];
System.arraycopy(bytes, 0, extendedBytes, 0, bytes.length);
extendedBytes[bytes.length] = 0;
inflater.setInput(extendedBytes);
try {
final int resultLength = inflater.inflate(xmlMessageBytes);
inflater.end();
if (!inflater.finished()) {
throw new RuntimeException("buffer not large enough.");
}
inflater.end();
return new String(xmlMessageBytes, 0, resultLength, StandardCharsets.UTF_8);
} catch (final DataFormatException e) {
return null;
}
}
项目:Android-UtilCode
文件:LogUtils.java
public static byte[] uncompress(byte[] input) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Inflater decompressor = new Inflater();
try {
decompressor.setInput(input);
final byte[] buf = new byte[2048];
while (!decompressor.finished()) {
int count = 0;
try {
count = decompressor.inflate(buf);
} catch (DataFormatException e) {
e.printStackTrace();
}
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
项目:Progetto-C
文件:PNGDecoder.java
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
try {
do {
int read = inflater.inflate(buffer, offset, length);
if(read <= 0) {
if(inflater.finished()) {
throw new EOFException();
}
if(inflater.needsInput()) {
refillInflater(inflater);
} else {
throw new IOException("Can't inflate " + length + " bytes");
}
} else {
offset += read;
length -= read;
}
} while(length > 0);
} catch (DataFormatException ex) {
throw (IOException)(new IOException("inflate error").initCause(ex));
}
}
项目:elasticsearch_my
文件:AbstractInternalHDRPercentiles.java
/**
* Read from a stream.
*/
protected AbstractInternalHDRPercentiles(StreamInput in) throws IOException {
super(in);
format = in.readNamedWriteable(DocValueFormat.class);
keys = in.readDoubleArray();
long minBarForHighestToLowestValueRatio = in.readLong();
final int serializedLen = in.readVInt();
byte[] bytes = new byte[serializedLen];
in.readBytes(bytes, 0, serializedLen);
ByteBuffer stateBuffer = ByteBuffer.wrap(bytes);
try {
state = DoubleHistogram.decodeFromCompressedByteBuffer(stateBuffer, minBarForHighestToLowestValueRatio);
} catch (DataFormatException e) {
throw new IOException("Failed to decode DoubleHistogram for aggregation [" + name + "]", e);
}
keyed = in.readBoolean();
}
项目:BilibiliClient
文件:BiliDanmukuCompressionTools.java
public static byte[] decompress(byte[] value) throws DataFormatException {
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
Inflater decompressor = new Inflater();
try {
decompressor.setInput(value);
final byte[] buf = new byte[1024];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
项目:BilibiliClient
文件:BiliDanmukuCompressionTools.java
public static byte[] decompress(byte[] value) throws DataFormatException {
ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
Inflater decompressor = new Inflater();
try {
decompressor.setInput(value);
final byte[] buf = new byte[1024];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
项目:odb-artax
文件:PNGDecoder.java
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
assert(buffer != this.buffer);
try {
do {
int read = inflater.inflate(buffer, offset, length);
if(read <= 0) {
if(inflater.finished()) {
throw new EOFException();
}
if(inflater.needsInput()) {
refillInflater(inflater);
} else {
throw new IOException("Can't inflate " + length + " bytes");
}
} else {
offset += read;
length -= read;
}
} while(length > 0);
} catch (DataFormatException ex) {
throw (IOException)(new IOException("inflate error").initCause(ex));
}
}
项目:discord.jar
文件:WebSocketClient.java
@Override
public void onMessage(ByteBuffer message) {
try {
//Thanks to ShadowLordAlpha for code and debugging.
//Get the compressed message and inflate it
StringBuilder builder = new StringBuilder();
Inflater decompresser = new Inflater();
byte[] bytes = message.array();
decompresser.setInput(bytes, 0, bytes.length);
byte[] result = new byte[128];
while (!decompresser.finished()) {
int resultLength = decompresser.inflate(result);
builder.append(new String(result, 0, resultLength, "UTF-8"));
}
decompresser.end();
// send the inflated message to the TextMessage method
onMessage(builder.toString());
} catch (DataFormatException | UnsupportedEncodingException e) {
e.printStackTrace();
}
}
项目:DIA-Umpire-Maven
文件:DIAPack.java
public void BuildDIAWindows() throws IOException, DataFormatException, IOException, IOException, IOException, InterruptedException {
if (dIA_Setting.DIAWindows == null || dIA_Setting.DIAWindows.isEmpty()) {
GetSpectrumParser();
}
DIAWindows = new ArrayList<>();
Object[] WindowRange = dIA_Setting.DIAWindows.keySet().toArray();
for (int i = 0; i < WindowRange.length; i++) {
XYData DiaWinMz = (XYData) WindowRange[i];
XYData LastWinMz = null;
if (i < WindowRange.length - 1) {
LastWinMz = (XYData) WindowRange[i + 1];
}
LCMSPeakDIAMS2 diawindow = new LCMSPeakDIAMS2(Filename, this, parameter, DiaWinMz, LastWinMz, GetSpectrumParser(), NoCPUs);
diawindow.Resume = Resume;
//pass the settings through to MS2 feature map
diawindow.datattype = dIA_Setting.dataType;
diawindow.ExportPeakCurveTable = ExportFragmentPeak;
diawindow.ExportPeakClusterTable = ExportPrecursorPeak;
DIAWindows.add(diawindow);
}
}
项目:JungleTree
文件:ByteBufUtils.java
public static byte[] inflate(byte[] input) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Inflater inflater = new Inflater();
inflater.setInput(input);
byte[] intermediate = new byte[1024];
while (!inflater.finished()) {
int read = inflater.inflate(intermediate);
out.write(intermediate, 0, read);
}
return out.toByteArray();
} catch (DataFormatException ex) {
throw new RuntimeException("Failed to inflate chunk data", ex);
}
}
项目:AndroidUtilCode-master
文件:LogUtils.java
public static byte[] uncompress(byte[] input) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Inflater decompressor = new Inflater();
try {
decompressor.setInput(input);
final byte[] buf = new byte[2048];
while (!decompressor.finished()) {
int count = 0;
try {
count = decompressor.inflate(buf);
} catch (DataFormatException e) {
e.printStackTrace();
}
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
项目:oscm
文件:RedirectSamlURLBuilderTest.java
private String decodeURLBase64DeflateString(final String input)
throws UnsupportedEncodingException, DataFormatException {
String urlDecoded = URLDecoder.decode(input, "UTF-8");
byte[] base64Decoded = Base64.decodeBase64(urlDecoded);
Inflater decompresser = new Inflater(true);
decompresser.setInput(base64Decoded);
StringBuilder result = new StringBuilder();
while (!decompresser.finished()) {
byte[] outputFraction = new byte[base64Decoded.length];
int resultLength = decompresser.inflate(outputFraction);
result.append(new String(outputFraction, 0, resultLength, "UTF-8"));
}
return result.toString();
}
项目:oscm
文件:RedirectEncoderTest.java
private String decodeURLBase64DeflateString(final String input)
throws UnsupportedEncodingException, DataFormatException {
String urlDecoded = URLDecoder.decode(input, "UTF-8");
byte[] base64Decoded = Base64.decodeBase64(urlDecoded);
Inflater decompresser = new Inflater(true);
decompresser.setInput(base64Decoded);
StringBuilder result = new StringBuilder();
while (!decompresser.finished()) {
byte[] outputFraction = new byte[base64Decoded.length];
int resultLength = decompresser.inflate(outputFraction);
result.append(new String(outputFraction, 0, resultLength, "UTF-8"));
}
return result.toString();
}
项目:compress
文件:DeflaterCompress.java
@Override
public byte[] uncompress(byte[] data) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Inflater decompressor = new Inflater();
try {
decompressor.setInput(data);
final byte[] buf = new byte[2048];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
} catch (DataFormatException e) {
e.printStackTrace();
} finally {
decompressor.end();
}
return bos.toByteArray();
}
项目:letv
文件:bs.java
public static byte[] b(byte[] bArr) throws UnsupportedEncodingException, DataFormatException {
int i = 0;
if (bArr == null || bArr.length == 0) {
return null;
}
Inflater inflater = new Inflater();
inflater.setInput(bArr, 0, bArr.length);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr2 = new byte[1024];
while (!inflater.needsInput()) {
int inflate = inflater.inflate(bArr2);
byteArrayOutputStream.write(bArr2, i, inflate);
i += inflate;
}
inflater.end();
return byteArrayOutputStream.toByteArray();
}
项目:lams
文件:CompressionTools.java
/** Decompress the byte array previously returned by
* compress */
public static byte[] decompress(byte[] value, int offset, int length) throws DataFormatException {
// Create an expandable byte array to hold the decompressed data
ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
Inflater decompressor = new Inflater();
try {
decompressor.setInput(value, offset, length);
// Decompress the data
final byte[] buf = new byte[1024];
while (!decompressor.finished()) {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
项目:BaseClient
文件:PNGDecoder.java
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
try {
do {
int read = inflater.inflate(buffer, offset, length);
if(read <= 0) {
if(inflater.finished()) {
throw new EOFException();
}
if(inflater.needsInput()) {
refillInflater(inflater);
} else {
throw new IOException("Can't inflate " + length + " bytes");
}
} else {
offset += read;
length -= read;
}
} while(length > 0);
} catch (DataFormatException ex) {
throw (IOException)(new IOException("inflate error").initCause(ex));
}
}
项目:fpm
文件:PbfBlobDecoder.java
public static byte[] inflate(PbfRawBlob rawBlob) throws InvalidProtocolBufferException {
Blob blob = Blob.parseFrom(rawBlob.getData());
byte[] blobData;
if (blob.hasRaw()) {
blobData = blob.getRaw().toByteArray();
}
else if (blob.hasZlibData()) {
Inflater inflater = new Inflater();
inflater.setInput(blob.getZlibData().toByteArray());
blobData = new byte[blob.getRawSize()];
try {
inflater.inflate(blobData);
}
catch (DataFormatException e) {
throw new OsmosisRuntimeException("Unable to decompress PBF blob.", e);
}
if (!inflater.finished()) {
throw new OsmosisRuntimeException("PBF blob contains incomplete compressed data.");
}
}
else {
throw new OsmosisRuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used.");
}
return blobData;
}
项目:monarch
文件:CliUtil.java
public static DeflaterInflaterData uncompressBytes(byte[] output, int compressedDataLength)
throws DataFormatException {
Inflater decompresser = new Inflater();
decompresser.setInput(output, 0, compressedDataLength);
byte[] buffer = new byte[512];
byte[] result = new byte[0];
int bytesRead;
while (!decompresser.needsInput()) {
bytesRead = decompresser.inflate(buffer);
byte[] newResult = new byte[result.length + bytesRead];
System.arraycopy(result, 0, newResult, 0, result.length);
System.arraycopy(buffer, 0, newResult, result.length, bytesRead);
result = newResult;
}
// System.out.println(new String(result));
decompresser.end();
return new DeflaterInflaterData(result.length, result);
}
项目:boohee_v5.6
文件:bs.java
public static byte[] b(byte[] bArr) throws UnsupportedEncodingException, DataFormatException {
int i = 0;
if (bArr == null || bArr.length == 0) {
return null;
}
Inflater inflater = new Inflater();
inflater.setInput(bArr, 0, bArr.length);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr2 = new byte[1024];
while (!inflater.needsInput()) {
int inflate = inflater.inflate(bArr2);
byteArrayOutputStream.write(bArr2, i, inflate);
i += inflate;
}
inflater.end();
return byteArrayOutputStream.toByteArray();
}
项目:boohee_v5.6
文件:NameValueBlockReader.java
public NameValueBlockReader(BufferedSource source) {
this.inflaterSource = new InflaterSource(new ForwardingSource(source) {
public long read(Buffer sink, long byteCount) throws IOException {
if (NameValueBlockReader.this.compressedLimit == 0) {
return -1;
}
long read = super.read(sink, Math.min(byteCount, (long) NameValueBlockReader.this
.compressedLimit));
if (read == -1) {
return -1;
}
NameValueBlockReader.this.compressedLimit = (int) (((long) NameValueBlockReader
.this.compressedLimit) - read);
return read;
}
}, new Inflater() {
public int inflate(byte[] buffer, int offset, int count) throws DataFormatException {
int result = super.inflate(buffer, offset, count);
if (result != 0 || !needsDictionary()) {
return result;
}
setDictionary(Spdy3.DICTIONARY);
return super.inflate(buffer, offset, count);
}
});
}
项目:LoRaWAN-Smart-Parking
文件:NameValueBlockReader.java
public List<String> readNameValueBlock(int length) throws IOException {
this.compressedLimit += length;
try {
int numberOfPairs = nameValueBlockIn.readInt();
if (numberOfPairs < 0) {
throw new IOException("numberOfPairs < 0: " + numberOfPairs);
}
if (numberOfPairs > 1024) {
throw new IOException("numberOfPairs > 1024: " + numberOfPairs);
}
List<String> entries = new ArrayList<String>(numberOfPairs * 2);
for (int i = 0; i < numberOfPairs; i++) {
String name = readString();
String values = readString();
if (name.length() == 0) throw new IOException("name.length == 0");
entries.add(name);
entries.add(values);
}
doneReading();
return entries;
} catch (DataFormatException e) {
throw new IOException(e.getMessage());
}
}
项目:LoRaWAN-Smart-Parking
文件:NameValueBlockReader.java
public List<String> readNameValueBlock(int length) throws IOException {
this.compressedLimit += length;
try {
int numberOfPairs = nameValueBlockIn.readInt();
if (numberOfPairs < 0) {
throw new IOException("numberOfPairs < 0: " + numberOfPairs);
}
if (numberOfPairs > 1024) {
throw new IOException("numberOfPairs > 1024: " + numberOfPairs);
}
List<String> entries = new ArrayList<String>(numberOfPairs * 2);
for (int i = 0; i < numberOfPairs; i++) {
String name = readString();
String values = readString();
if (name.length() == 0) throw new IOException("name.length == 0");
entries.add(name);
entries.add(values);
}
doneReading();
return entries;
} catch (DataFormatException e) {
throw new IOException(e.getMessage());
}
}
项目:cr-private-server
文件:DataStream.java
public String getZipString() {
int length = getBInt() - 4;
int zlength = getLInt();
if (remaining() > length) {
Inflater decompressor = new Inflater();
decompressor.setInput(buffer, offset, length);
offset += length;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(zlength);
byte[] buf = new byte[1024];
int count;
while ((!decompressor.finished()) && ((count = decompressor.inflate(buf)) > 0)) {
bos.write(buf, 0, count);
}
decompressor.end();
bos.close();
return new String(bos.toByteArray(), UTF8_CHARSET);
} catch (DataFormatException | IOException ignored) {
}
}
return null;
}
项目:HeadlineNews
文件:LogUtils.java
public static byte[] uncompress(final byte[] input) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Inflater decompressor = new Inflater();
try {
decompressor.setInput(input);
final byte[] buf = new byte[2048];
while (!decompressor.finished()) {
int count = 0;
try {
count = decompressor.inflate(buf);
} catch (DataFormatException e) {
e.printStackTrace();
}
bos.write(buf, 0, count);
}
} finally {
decompressor.end();
}
return bos.toByteArray();
}
项目:odb-little-fortune-planet
文件:PNGDecoder.java
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
assert(buffer != this.buffer);
try {
do {
int read = inflater.inflate(buffer, offset, length);
if(read <= 0) {
if(inflater.finished()) {
throw new EOFException();
}
if(inflater.needsInput()) {
refillInflater(inflater);
} else {
throw new IOException("Can't inflate " + length + " bytes");
}
} else {
offset += read;
length -= read;
}
} while(length > 0);
} catch (DataFormatException ex) {
throw (IOException)(new IOException("inflate error").initCause(ex));
}
}
项目:Towan
文件:PNGDecoder.java
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
try {
do {
int read = inflater.inflate(buffer, offset, length);
if(read <= 0) {
if(inflater.finished()) {
throw new EOFException();
}
if(inflater.needsInput()) {
refillInflater(inflater);
} else {
throw new IOException("Can't inflate " + length + " bytes");
}
} else {
offset += read;
length -= read;
}
} while(length > 0);
} catch (DataFormatException ex) {
throw (IOException)(new IOException("inflate error").initCause(ex));
}
}
项目:automatic-variants
文件:VariantProfile.java
public boolean catalogNif(String nifPath) {
if (!nifInfoDatabase.containsKey(nifPath)) {
try {
LShrinkArray nifRawData = BSA.getUsedFile(nifPath);
if (nifRawData != null) {
ArrayList<TextureSet> nifTextures = VariantFactory.loadNif(nifPath, nifRawData);
Map<Integer, TextureSet> nifData = new HashMap<>();
nifInfoDatabase.put(nifPath.toUpperCase(), nifData);
for (TextureSet t : nifTextures) {
textures.put(t.getIndex(), t.getTextures());
nifData.put(t.getIndex(), t);
}
return true;
} else {
SPGlobal.log(toString(), " * Could not catalog nif because it could not find file: " + nifPath);
}
} catch (IOException | DataFormatException ex) {
SPGlobal.logException(ex);
}
}
return false;
}
项目:mi-firma-android
文件:Ceres.java
/** Descomprime un certificado contenido en la tarjeta CERES.
* @param compressedCertificate Certificado comprimido en ZIP a partir del 9 octeto.
* @return Certificado codificado.
* @throws IOException Cuando se produce un error en la descompresión del certificado. */
private static byte[] deflate(final byte[] compressedCertificate) throws IOException {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final Inflater decompressor = new Inflater();
decompressor.setInput(compressedCertificate, 8, compressedCertificate.length - 8);
final byte[] buf = new byte[1024];
try {
// Descomprimimos los datos
while (!decompressor.finished()) {
final int count = decompressor.inflate(buf);
if (count == 0) {
throw new DataFormatException();
}
buffer.write(buf, 0, count);
}
// Obtenemos los datos descomprimidos
return buffer.toByteArray();
}
catch (final DataFormatException ex) {
throw new IOException("Error al descomprimir el certificado: " + ex, ex); //$NON-NLS-1$
}
}
项目:mi-firma-android
文件:Dnie.java
/** Descomprime un certificado contenido en el DNIe.
* @param compressedCertificate Certificado comprimido en ZIP a partir del 9 byte.
* @return Certificado codificado.
* @throws IOException Cuando se produce un error en la descompresion del certificado. */
private static byte[] deflate(final byte[] compressedCertificate) throws IOException {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final Inflater decompressor = new Inflater();
decompressor.setInput(compressedCertificate, 8, compressedCertificate.length - 8);
final byte[] buf = new byte[1024];
try {
// Descomprimimos los datos
while (!decompressor.finished()) {
final int count = decompressor.inflate(buf);
if (count == 0) {
throw new DataFormatException();
}
buffer.write(buf, 0, count);
}
// Obtenemos los datos descomprimidos
return buffer.toByteArray();
}
catch (final DataFormatException ex) {
throw new IOException("Error al descomprimir el certificado: " + ex, ex); //$NON-NLS-1$
}
}