Tabnine Logo
IoBuffer.asInputStream
Code IndexAdd Tabnine to your IDE (free)

How to use
asInputStream
method
in
org.apache.mina.codec.IoBuffer

Best Java code snippets using org.apache.mina.codec.IoBuffer.asInputStream (Showing top 5 results out of 315)

origin: apache/mina

@SuppressWarnings("unchecked")
public <L extends GeneratedMessage> L get(Class<L> clazz, ExtensionRegistryLite registry)
    throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
  Method parseMethod = clazz.getDeclaredMethod("parseFrom", InputStream.class, ExtensionRegistryLite.class);
  return (L) parseMethod.invoke(null, input.asInputStream(), registry);
}
origin: apache/mina

  @SuppressWarnings("unchecked")
  @Override
  public IN decode(IoBuffer input) {
    try {
      return (IN) parseMethod.invoke(null, input.asInputStream(), registry);
    } catch (Exception e) {
      throw new ProtocolDecoderException(e);
    }
  }
}
origin: apache/mina

  @SuppressWarnings("unchecked")
  @Override
  public IN decode(final IoBuffer input) {
    try {
      ObjectInputStream ois = new ObjectInputStream(input.asInputStream());
      IN s = (IN) ois.readObject();
      ois.close();
      return s;
    } catch (Exception ex) {
      throw new ProtocolDecoderException(ex);
    }
  }
}
origin: apache/mina

@Test
public void testInputStreamGetByte() throws IOException {
  String hw = "HelloWorld";
  IoBuffer bb = IoBuffer.wrap(hw.getBytes());
  InputStream is = bb.asInputStream();
  for (int i = 0; i < 10; i++) {
    assertEquals(i, bb.position());
    assertEquals(hw.getBytes()[i], is.read());
  }
  assertEquals(-1, is.read());
}
origin: apache/mina

@Test
public void testInputStreamGetByteArray() throws IOException {
  String hw = "HelloWorld";
  IoBuffer bb = IoBuffer.wrap(hw.getBytes());
  InputStream is = bb.asInputStream();
  byte array[] = new byte[15];
  assertEquals(5, is.read(array, 0, 5));
  assertEquals(5, bb.position());
  assertEquals(5, is.read(array, 5, 10));
  assertEquals(10, bb.position());
  for (int i = 0; i < 10; i++) {
    assertEquals(hw.getBytes()[i], array[i]);
  }
}
org.apache.mina.codecIoBufferasInputStream

Javadoc

Provides an input stream which is actually reading the IoBufferinstance.

Further reads on the returned InputStream move the reading head of the IoBuffer instance used for its creation

Popular methods of IoBuffer

  • get
  • remaining
  • add
    Add one or more ByteBuffer to the current IoBuffer
  • array
  • capacity
  • getChar
  • getDouble
  • getFloat
  • getInt
  • getLong
  • getShort
  • hasRemaining
  • getShort,
  • hasRemaining,
  • isDirect,
  • limit,
  • order,
  • position,
  • put,
  • putChar,
  • putDouble

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • compareTo (BigDecimal)
  • getSharedPreferences (Context)
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Reference (javax.naming)
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now