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


Java DataFormatException.getMessage方法代码示例

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


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

示例1: unwrap

import java.util.zip.DataFormatException; //导入方法依赖的package包/类
@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();
    }
}
 
开发者ID:ZhangJiupeng,项目名称:AgentX,代码行数:20,代码来源:CompressWrapper.java

示例2: readNameValueBlock

import java.util.zip.DataFormatException; //导入方法依赖的package包/类
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());
  }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:27,代码来源:NameValueBlockReader.java

示例3: read

import java.util.zip.DataFormatException; //导入方法依赖的package包/类
/**
 * Reads uncompressed data into an array of bytes. If <code>len</code> is not
 * zero, the method will block until some input can be decompressed; otherwise,
 * no bytes are read and <code>0</code> is returned.
 *
 * @param b   the buffer into which the data is read
 * @param off the start offset in the destination array <code>b</code>
 * @param len the maximum number of bytes read
 * @return the actual number of bytes read, or -1 if the end of the
 * compressed input is reached or a preset dictionary is needed
 * @throws NullPointerException      If <code>b</code> is <code>null</code>.
 * @throws IndexOutOfBoundsException If <code>off</code> is negative,
 *                                   <code>len</code> is negative, or <code>len</code> is greater than
 *                                   <code>b.length - off</code>
 * @throws ZipException              if a ZIP format error has occurred
 * @throws IOException               if an I/O error has occurred
 */
public int read(byte[] b, int off, int len) throws IOException {
	ensureOpen();
	if (b == null) {
		throw new NullPointerException();
	} else if (off < 0 || len < 0 || len > b.length - off) {
		throw new IndexOutOfBoundsException();
	} else if (len == 0) {
		return 0;
	}
	try {
		int n;
		while ((n = inf.inflate(b, off, len)) == 0) {
			if (inf.finished() || inf.needsDictionary()) {
				reachEOF = true;
				return -1;
			}
			if (inf.needsInput()) {
				fill();
			}
		}
		return n;
	} catch (DataFormatException e) {
		String s = e.getMessage();
		throw new ZipException(s != null ? s : "Invalid ZLIB data format");
	}
}
 
开发者ID:funtl,项目名称:framework,代码行数:44,代码来源:InflaterInputStream.java

示例4: decompress

import java.util.zip.DataFormatException; //导入方法依赖的package包/类
@Override
public synchronized int decompress(byte[] b, int off, int len) 
  throws IOException {
  try {
    return super.inflate(b, off, len);
  } catch (DataFormatException dfe) {
    throw new IOException(dfe.getMessage());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:BuiltInZlibInflater.java

示例5: inflate

import java.util.zip.DataFormatException; //导入方法依赖的package包/类
/**
 * Utility method to decompress a compressed byte array, using the given {@link Inflater}.
 * @param source The compressed array.
 * @param off The offset in {@code source}.
 * @param len The number of bytes in {@code source}.
 * @param infl The inflater to use for decompression.
 * @return The decompressed byte array.
 * @throws IOException If input array contains invalid data.
 */
public static byte[] inflate(byte[] source, int off, int len, Inflater infl) throws IOException {
	infl.setInput(source, off, len);
	byte[] buf = new byte[1024];
	try (DirectByteArrayOutputStream bos = new DirectByteArrayOutputStream(buf.length)) {
		int n;
		while ((n = infl.inflate(buf)) > 0)
			bos.write(buf, 0, n);
		return Arrays.copyOf(bos.toByteArray(), bos.size());
	} catch (DataFormatException e) {
		throw new IOException("Cannot inflate data: "+e.getMessage(), e);
	}
}
 
开发者ID:matthieu-labas,项目名称:JRF,代码行数:22,代码来源:Utils.java


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