java.io.DataInputStream.available()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(350)

本文整理了Java中java.io.DataInputStream.available()方法的一些代码示例,展示了DataInputStream.available()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataInputStream.available()方法的具体详情如下:
包路径:java.io.DataInputStream
类名称:DataInputStream
方法名:available

DataInputStream.available介绍

暂无

代码示例

代码示例来源:origin: netty/netty

  1. @Override
  2. public int available() throws IOException {
  3. return in.available();
  4. }

代码示例来源:origin: redisson/redisson

  1. @Override
  2. public int available() throws IOException {
  3. return in.available();
  4. }

代码示例来源:origin: wildfly/wildfly

  1. @Override
  2. public int available() throws IOException {
  3. return in.available();
  4. }

代码示例来源:origin: scouter-project/scouter

  1. public int available() throws IOException {
  2. return this.din == null ? 0 : this.din.available();
  3. }

代码示例来源:origin: scouter-project/scouter

  1. public int available() throws IOException {
  2. return this.din == null ? 0 : this.din.available();
  3. }

代码示例来源:origin: scouter-project/scouter

  1. public int available() throws IOException {
  2. return this.din == null ? 0 : this.din.available();
  3. }

代码示例来源:origin: hankcs/HanLP

  1. @Override
  2. public boolean hasNext()
  3. {
  4. try
  5. {
  6. boolean next = in.available() > 0;
  7. if (!next) in.close();
  8. return next;
  9. }
  10. catch (IOException e)
  11. {
  12. throw new RuntimeException(e);
  13. }
  14. }

代码示例来源:origin: mpusher/mpush

  1. @SuppressWarnings("unchecked")
  2. private <T> T asObject(byte[] bytes) throws Exception {
  3. ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes);
  4. DataInputStream in = new DataInputStream(byteIn);
  5. byte[] body = new byte[in.available()];
  6. in.readFully(body);
  7. ObjectInputStream objectIn = new ObjectInputStream(new ByteArrayInputStream(body));
  8. return (T) objectIn.readObject();
  9. }

代码示例来源:origin: apache/usergrid

  1. private static InputStream getCertificateStream () throws IOException {
  2. InputStream in = ChopUtils.class.getClassLoader().getResourceAsStream( "runner.cer" );
  3. DataInputStream dis = new DataInputStream( in );
  4. byte[] bytes = new byte[ dis.available() ];
  5. dis.readFully( bytes );
  6. return new ByteArrayInputStream( bytes );
  7. }

代码示例来源:origin: org.apache.poi/poi

  1. @Override
  2. @SuppressForbidden("just delegating the call")
  3. public int available() throws IOException {
  4. return _currentSize - _currentPos + _is.available();
  5. }
  6. private void fillNextBuffer() throws IOException {

代码示例来源:origin: redisson/redisson

  1. private ClassBody getClassBody(Object task) {
  2. Class<?> c = task.getClass();
  3. ClassBody result = class2body.get(c);
  4. if (result == null) {
  5. String className = c.getName();
  6. String classAsPath = className.replace('.', '/') + ".class";
  7. InputStream classStream = c.getClassLoader().getResourceAsStream(classAsPath);
  8. byte[] lambdaBody = null;
  9. byte[] classBody;
  10. try {
  11. DataInputStream s = new DataInputStream(classStream);
  12. classBody = new byte[s.available()];
  13. s.readFully(classBody);
  14. } catch (IOException e) {
  15. throw new IllegalArgumentException(e);
  16. } finally {
  17. try {
  18. classStream.close();
  19. } catch (IOException e) {
  20. // skip
  21. }
  22. }
  23. result = new ClassBody(lambdaBody, classBody, className);
  24. class2body.put(c, result);
  25. }
  26. return result;
  27. }

代码示例来源:origin: redisson/redisson

  1. private ClassBody getClassBody(Object task) {
  2. Class<?> c = task.getClass();
  3. ClassBody result = class2body.get(c);
  4. if (result == null) {
  5. String className = c.getName();
  6. String classAsPath = className.replace('.', '/') + ".class";
  7. InputStream classStream = c.getClassLoader().getResourceAsStream(classAsPath);
  8. byte[] lambdaBody = null;
  9. byte[] classBody;
  10. try {
  11. DataInputStream s = new DataInputStream(classStream);
  12. classBody = new byte[s.available()];
  13. s.readFully(classBody);
  14. } catch (IOException e) {
  15. throw new IllegalArgumentException(e);
  16. } finally {
  17. try {
  18. classStream.close();
  19. } catch (IOException e) {
  20. // skip
  21. }
  22. }
  23. result = new ClassBody(lambdaBody, classBody, className);
  24. class2body.put(c, result);
  25. }
  26. return result;
  27. }

代码示例来源:origin: apache/hbase

  1. @Override
  2. protected ByteBuffer internalDecodeKeyValues(DataInputStream source, int allocateHeaderLength,
  3. int skipLastBytes, HFileBlockDefaultDecodingContext decodingCtx) throws IOException {
  4. int decompressedSize = source.readInt();
  5. ByteBuffer buffer = ByteBuffer.allocate(decompressedSize +
  6. allocateHeaderLength);
  7. buffer.position(allocateHeaderLength);
  8. FastDiffCompressionState state = new FastDiffCompressionState();
  9. while (source.available() > skipLastBytes) {
  10. uncompressSingleKeyValue(source, buffer, state);
  11. afterDecodingKeyValue(source, buffer, decodingCtx);
  12. }
  13. if (source.available() != skipLastBytes) {
  14. throw new IllegalStateException("Read too much bytes.");
  15. }
  16. return buffer;
  17. }

代码示例来源:origin: libgdx/libgdx

  1. while (din.available() > 0 && type != ']') {
  2. final JsonValue val = parse(din, type);
  3. val.parent = result;

代码示例来源:origin: libgdx/libgdx

  1. while (din.available() > 0 && type != ']') {
  2. final JsonValue val = parse(din, type);
  3. val.parent = result;

代码示例来源:origin: libgdx/libgdx

  1. while (din.available() > 0 && type != '}') {
  2. final String key = parseString(din, true, type);
  3. final JsonValue child = parse(din, valueType == 0 ? din.readByte() : valueType);

代码示例来源:origin: libgdx/libgdx

  1. while (din.available() > 0 && type != '}') {
  2. final String key = parseString(din, true, type);
  3. final JsonValue child = parse(din, valueType == 0 ? din.readByte() : valueType);

代码示例来源:origin: apache/geode

  1. private void assertNoMoreInput(DataInputStream in) throws IOException {
  2. assertEquals(0, in.available());
  3. }
  4. }

代码示例来源:origin: apache/flink

  1. public static final void testSerialization(String[] values) throws IOException {
  2. ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
  3. DataOutputStream serializer = new DataOutputStream(baos);
  4. for (String value : values) {
  5. StringValue.writeString(value, serializer);
  6. }
  7. serializer.close();
  8. baos.close();
  9. ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  10. DataInputStream deserializer = new DataInputStream(bais);
  11. int num = 0;
  12. while (deserializer.available() > 0) {
  13. String deser = StringValue.readString(deserializer);
  14. assertEquals("DeserializedString differs from original string.", values[num], deser);
  15. num++;
  16. }
  17. assertEquals("Wrong number of deserialized values", values.length, num);
  18. }

代码示例来源:origin: apache/flink

  1. while (validate.available() > 0) {
  2. String deser = StringValue.readString(validate);

相关文章