Java 8 SequenceInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SequenceInputStream class.

This code example shows how to use the following methods:
 */ 
@Provider 
public class CustomInterceptor implements ReaderInterceptor, WriterInterceptor { 
 
    public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
        context.setInputStream(new SequenceInputStream(new ByteArrayInputStream("READ ".getBytes()), context.getInputStream()));
        return context.proceed();
    } 
 
    public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
	context.getOutputStream().write("WRITE ".getBytes());
        context.proceed();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
 */ 
@Provider 
public class DynamicallyBoundInterceptor implements ReaderInterceptor, WriterInterceptor { 
 
    public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
        context.setInputStream(new SequenceInputStream(new ByteArrayInputStream("READ ".getBytes()), context.getInputStream()));
        return context.proceed();
    } 
 
    public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
	context.getOutputStream().write("WRITE ".getBytes());
        context.proceed();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
@Provider 
@Intercepted 
public class NameBoundInterceptor implements ReaderInterceptor, WriterInterceptor { 
 
    public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
        context.setInputStream(new SequenceInputStream(new ByteArrayInputStream("READ ".getBytes()), context.getInputStream()));
        return context.proceed();
    } 
 
    public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
	context.getOutputStream().write("WRITE ".getBytes());
        context.proceed();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:read
        } 
 
        buf = new byte[10];
        simple1 = new Support_ASimpleInputStream(s1);
        simple2 = new Support_ASimpleInputStream(s2);
        si = new SequenceInputStream(simple1, simple2);
        try { 
            si.read(buf, -1, 1);
            fail("IndexOutOfBoundsException was not thrown");
        } catch (IndexOutOfBoundsException e) {
            // Expected 
        } 
        try { 
            si.read(buf, 0, -1);
            fail("IndexOutOfBoundsException was not thrown");
        } catch (IndexOutOfBoundsException e) {
            // Expected 
        } 
        try { 
            si.read(buf, 1, 10);

6
CodeRank
This code example shows how to use the following methods:
@Provider 
public class DynamicallyBoundFilter implements ContainerRequestFilter, ContainerResponseFilter { 
 
    public void filter(ContainerRequestContext requestContext) throws IOException {
        if (requestContext.hasEntity()) {
            requestContext.setEntityStream(new SequenceInputStream(new ByteArrayInputStream("DYN_MATCH_IN".getBytes()), requestContext.getEntityStream()));
        } 
    } 
 
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
        if (responseContext.hasEntity()) {
            responseContext.setEntity("" + responseContext.getEntity() + "DYN_MATCH_OUT", null, MediaType.TEXT_PLAIN_TYPE);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
@Filtered 
public class NameBoundFilter implements ContainerRequestFilter, ContainerResponseFilter { 
 
    public void filter(ContainerRequestContext requestContext) throws IOException {
        if (requestContext.hasEntity()) {
            requestContext.setEntityStream(new SequenceInputStream(new ByteArrayInputStream("NAM_MATCH_IN".getBytes()), requestContext.getEntityStream()));
        } 
    } 
 
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
        if (responseContext.hasEntity()) {
            responseContext.setEntity("" + responseContext.getEntity() + "NAM_MATCH_OUT", null, MediaType.TEXT_PLAIN_TYPE);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
@Provider 
public class GlobalFilter implements ContainerRequestFilter, ContainerResponseFilter { 
 
    public void filter(ContainerRequestContext requestContext) throws IOException {
        if (requestContext.hasEntity()) {
            requestContext.setEntityStream(new SequenceInputStream(new ByteArrayInputStream("PRE_MATCH_IN".getBytes()), requestContext.getEntityStream()));
        } 
    } 
 
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
        if (responseContext.hasEntity()) {
            responseContext.setEntity("" + responseContext.getEntity() + "PRE_MATCH_OUT", null, MediaType.TEXT_PLAIN_TYPE);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:
 */ 
@Provider 
public class DynamicallyBoundInterceptor implements ReaderInterceptor, WriterInterceptor { 
 
    public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
        context.setInputStream(new SequenceInputStream(new ByteArrayInputStream("READ ".getBytes()), context.getInputStream()));
        return context.proceed();
    } 
 
    public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
	context.getOutputStream().write("WRITE ".getBytes());
        context.proceed();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
 */ 
@Provider 
public class CustomInterceptor implements ReaderInterceptor, WriterInterceptor { 
 
    public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
        context.setInputStream(new SequenceInputStream(new ByteArrayInputStream("READ ".getBytes()), context.getInputStream()));
        return context.proceed();
    } 
 
    public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
	context.getOutputStream().write("WRITE ".getBytes());
        context.proceed();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:read
        } 
 
        buf = new byte[10];
        simple1 = new Support_ASimpleInputStream(s1);
        simple2 = new Support_ASimpleInputStream(s2);
        si = new SequenceInputStream(simple1, simple2);
        try { 
            si.read(buf, -1, 1);
            fail("IndexOutOfBoundsException was not thrown");
        } catch (IndexOutOfBoundsException e) {
            // Expected 
        } 
        try { 
            si.read(buf, 0, -1);
            fail("IndexOutOfBoundsException was not thrown");
        } catch (IndexOutOfBoundsException e) {
            // Expected 
        } 
        try { 
            si.read(buf, 1, 10);

5
CodeRank

Related Java 8 SequenceInputStream Questions & Answers:

See Code Examples for Java 8 SequenceInputStream Methods: