Package com.alibaba.citrus.util.io

Examples of com.alibaba.citrus.util.io.ByteArray


        // write��pop
        ostream.write("abc".getBytes());
        ostream.flush();

        ByteArray bytes = requestContext.popByteBuffer();

        assertEquals("abc", new String(bytes.toByteArray()));

        // write, push, write, push, write, pop, pop, pop
        ostream.write("abc".getBytes());
        ostream.flush();

        requestContext.pushBuffer();
        ostream.write("def".getBytes());
        ostream.flush();

        requestContext.pushBuffer();
        ostream.write("ghi".getBytes());
        ostream.flush();

        bytes = requestContext.popByteBuffer();
        assertEquals("ghi", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("def", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("abc", new String(bytes.toByteArray()));
    }
View Full Code Here


        // write��pop
        writer.write("abc");
        writer.flush();

        ByteArray bytes = requestContext.popByteBuffer();

        assertEquals("abc", new String(bytes.toByteArray()));

        // write, push, write, push, write, pop, pop, pop
        writer.write("abc");
        writer.flush();

        requestContext.pushBuffer();
        writer.write("def");
        writer.flush();

        requestContext.pushBuffer();
        writer.write("ghi");
        writer.flush();

        bytes = requestContext.popByteBuffer();
        assertEquals("ghi", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("def", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("abc", new String(bytes.toByteArray()));
    }
View Full Code Here

        if (writer != null) {
            throw new IllegalStateException("Unable to popByteBuffer() since the getWriter() method has been called");
        }

        if (stream == null) {
            return new ByteArray(EMPTY_BYTE_ARRAY, 0, 0);
        } else {
            flushBufferAdapter();

            ByteArrayOutputStream block = bytesStack.pop();
View Full Code Here

            }

            flushBufferAdapter();

            OutputStream ostream = super.getOutputStream();
            ByteArray bytes = popByteBuffer();

            bytes.writeTo(ostream);

            log.debug("Committed buffered bytes to the Servlet output stream");
        }

        // ���chars
View Full Code Here

            Method defineClassMethod = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class,
                    int.class, int.class);

            defineClassMethod.setAccessible(true);

            ByteArray ba = StreamUtil.readBytes(
                    LoggerHacker.class.getClassLoader().getResource(className.replace('.', '/') + ".class")
                            .openStream(), true);

            try {
                defineClassMethod.invoke(loader, className, ba.getRawBytes(), ba.getOffset(), ba.getLength());
            } catch (InvocationTargetException e) {
                throw e.getTargetException();
            }
        } catch (Throwable e) {
            slf4jLog.debug("Failed to define {}: {}", className, e.getMessage());
View Full Code Here

            buffer.write(b, off, len);
        }

        @Override
        public void flush() throws IOException {
            ByteArray bytes = buffer.toByteArray();

            if (bytes.getLength() > 0) {
                ByteArrayInputStream inputBytes = new ByteArrayInputStream(bytes.getRawBytes(), bytes.getOffset(),
                        bytes.getLength());
                InputStreamReader reader = new InputStreamReader(inputBytes, charset);

                StreamUtil.io(reader, writer, true, false);
                writer.flush();
View Full Code Here

            unexpectedException(e);
        } finally {
            ostream.close();
        }

        ByteArray bytes = ostream.toByteArray();

        javaCharset = getJavaCharset(javaCharset);

        return new String(bytes.getRawBytes(), bytes.getOffset(), bytes.getLength(), javaCharset);
    }
View Full Code Here

        // write��pop
        ostream.write("abc".getBytes());
        ostream.flush();

        ByteArray bytes = requestContext.popByteBuffer();

        assertEquals("abc", new String(bytes.toByteArray()));

        // write, push, write, push, write, pop, pop, pop
        ostream.write("abc".getBytes());
        ostream.flush();

        requestContext.pushBuffer();
        ostream.write("def".getBytes());
        ostream.flush();

        requestContext.pushBuffer();
        ostream.write("ghi".getBytes());
        ostream.flush();

        bytes = requestContext.popByteBuffer();
        assertEquals("ghi", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("def", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("abc", new String(bytes.toByteArray()));
    }
View Full Code Here

        // write��pop
        writer.write("abc");
        writer.flush();

        ByteArray bytes = requestContext.popByteBuffer();

        assertEquals("abc", new String(bytes.toByteArray()));

        // write, push, write, push, write, pop, pop, pop
        writer.write("abc");
        writer.flush();

        requestContext.pushBuffer();
        writer.write("def");
        writer.flush();

        requestContext.pushBuffer();
        writer.write("ghi");
        writer.flush();

        bytes = requestContext.popByteBuffer();
        assertEquals("ghi", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("def", new String(bytes.toByteArray()));

        bytes = requestContext.popByteBuffer();
        assertEquals("abc", new String(bytes.toByteArray()));
    }
View Full Code Here

        if (writer != null) {
            throw new IllegalStateException("Unable to popByteBuffer() since the getWriter() method has been called");
        }

        if (stream == null) {
            return new ByteArray(EMPTY_BYTE_ARRAY, 0, 0);
        } else {
            flushBufferAdapter();

            ByteArrayOutputStream block = bytesStack.pop();
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.util.io.ByteArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.