Package java.io

Examples of java.io.ByteArrayOutputStream.toByteArray()


    rewriteDOM(doc,input.getURL());

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    tidy.pprint(doc,bos);

    input.setContent(bos.toByteArray());
   
    return input;
  }

View Full Code Here


        out.writeObject( session );
        out.close();
        bos.close();

        // Get the bytes of the serialized object
        final byte[] b1 = bos.toByteArray();

        ByteArrayInputStream bais = new ByteArrayInputStream( b1 );
        StatefulSession session2 = ruleBase.newStatefulSession( bais );
        bais.close();
View Full Code Here

        out = new ObjectOutputStream( bos );
        out.writeObject( session2 );
        out.close();
        bos.close();

        final byte[] b2 = bos.toByteArray();

        // bytes should be the same.
        if ( !areByteArraysEqual( b1,
                                  b2 ) ) {
            throw new IllegalArgumentException( "byte streams for serialisation test are not equal" );
View Full Code Here

                                                                 new ObjectMarshallingStrategy[]{strategy} );

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        marshaller.marshall( bos,
                             ksession );
        final byte[] b1 = bos.toByteArray();
        bos.close();

        ByteArrayInputStream bais = new ByteArrayInputStream( b1 );
        StatefulKnowledgeSession ksession2 = marshaller.unmarshall( bais,
                                                                    new SessionConfiguration(),
View Full Code Here

        bais.close();

        bos = new ByteArrayOutputStream();
        marshaller.marshall( bos,
                             ksession2 );
        final byte[] b2 = bos.toByteArray();
        bos.close();

        // bytes should be the same.
        if ( !areByteArraysEqual( b1,
                                  b2 ) ) {
View Full Code Here

        Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKnowledgeBase() );
    

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        marshaller.marshall( baos, ksession );
        byte[] b1 = baos.toByteArray();
        session.halt();
        session.dispose();
        Thread.sleep(400);
       
        ByteArrayInputStream bais = new ByteArrayInputStream( b1 );       
View Full Code Here

            // get file as output stream       
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            ftp.get(out, remoteBinaryFile);
   
            // convert to byte array
            byte[] result1 = out.toByteArray();
   
            // put this
            String filename = generateRandomFilename();
            ftp.put(new ByteArrayInputStream(result1), filename);
   
View Full Code Here

                monitorEx.transferStarted(TransferDirection.DOWNLOAD, remoteFile);
            ByteArrayOutputStream result = new ByteArrayOutputStream(transferBufferSize);
            getData(result, remoteFile);
            validateTransfer();
            downloadCount++;
            return result == null ? null : result.toByteArray();
        }
        catch (FTPException ex) {
            throw ex;
        }
        catch (ControlChannelIOException ex) {
View Full Code Here

            StreamResult result = new StreamResult(baos);
            transformer.transform(source, result);
        } catch (TransformerException e) {
            throw new WsException("Error transforming WSDL: " + e.getMessage());
        }
        return baos.toByteArray();
    }

    /**
     * Adapts the location of the service.
     *
 
View Full Code Here

        try {
            while ((len = in.read(buffer)) >= 0) {
                out.write(buffer, 0, len);
            }
   
            return out.toByteArray();
        } finally {
            try {
                in.close();
                out.close();
            } catch (IOException ignore) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.