Package java.io

Examples of java.io.PushbackInputStream


    }

    private String findBoundaryFromInputStream() throws IOException {
        InputStream is = message.getContent(InputStream.class);
        //boundary should definitely be in the first 2K;
        PushbackInputStream in = new PushbackInputStream(is, 4096);
        byte buf[] = new byte[2048];
        int i = in.read(buf);
        String msg = IOUtils.newStringFromBytes(buf, 0, i);
        in.unread(buf, 0, i);
       
        // Reset the input stream since we'll need it again later
        message.setContent(InputStream.class, in);

        // Use regex to get the boundary and return null if it's not found
View Full Code Here


//                System.out.write(b, off, r);
//                System.out.flush();
//                return r;
//            }
//        };
        extract(new PushbackInputStream(in, 2));
    }
View Full Code Here

    private static InputStream getNonEmptyContent(
        HttpURLConnection connection
    ) {
        InputStream in = null;
        try {
            PushbackInputStream pin =
                new PushbackInputStream(connection.getInputStream());
            int c = pin.read();
            if (c != -1) {
                pin.unread((byte)c);
                in = pin;
            }
        } catch (IOException ioe) {
            // ignore
        }   
View Full Code Here

   * @tests java.io.PushbackInputStream#PushbackInputStream(java.io.InputStream)
   */
  public void test_ConstructorLjava_io_InputStream() {
    // Test for method java.io.PushbackInputStream(java.io.InputStream)
    try {
      pis = new PushbackInputStream(new ByteArrayInputStream("Hello"
          .getBytes()));
      pis.unread("He".getBytes());
    } catch (IOException e) {
      // Correct
      // Pushback buffer should be full
View Full Code Here

   *        int)
   */
  public void test_ConstructorLjava_io_InputStreamI() {
    // Test for method java.io.PushbackInputStream(java.io.InputStream, int)
    try {
      pis = new PushbackInputStream(new ByteArrayInputStream("Hello"
          .getBytes()), 5);
      pis.unread("Hellos".getBytes());
    } catch (IOException e) {
      // Correct
      // Pushback buffer should be full
View Full Code Here

   * Sets up the fixture, for example, open a network connection. This method
   * is called before a test is executed.
   */
  protected void setUp() {

    pis = new PushbackInputStream(new ByteArrayInputStream(fileString
        .getBytes()), 65535);
  }
View Full Code Here

            throw new IOException("Content length exceeds maximum upload size");
        }

        parseMultiPart(
                new TokenStream(
                        new PushbackInputStream(
                                new BufferedInputStream(request.getInputStream()),
                                MAX_BOUNDARY_SIZE)), getBoundary(request.getContentType()));
    }
View Full Code Here

    private static InputStream getNonEmptyContent(
        HttpURLConnection connection
    ) {
        InputStream in = null;
        try {
            PushbackInputStream pin =
                new PushbackInputStream(connection.getInputStream());
            int c = pin.read();
            if (c != -1) {
                pin.unread((byte)c);
                in = pin;
            }
        } catch (IOException ioe) {
            // ignore
        }   
View Full Code Here

            response.setContentLength(-1);
            response.setStatus(HttpServletResponse.SC_OK);
            response.getOutputStream().flush();
            handler.setOutputStream(response.getOutputStream());

            PushbackInputStream in =
                    new PushbackInputStream(request.getInputStream());
            for (;;) {
                try {
                    ChannelBuffer buffer = read(in);
                    if (buffer == null) {
                        break;
View Full Code Here

            channel.socket.connect(
                    remoteAddress, channel.getConfig().getConnectTimeoutMillis());
            connected = true;

            // Obtain I/O stream.
            channel.in = new PushbackInputStream(channel.socket.getInputStream(), 1);
            channel.out = channel.socket.getOutputStream();

            // Fire events.
            future.setSuccess();
            if (!bound) {
View Full Code Here

TOP

Related Classes of java.io.PushbackInputStream

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.