Package javax.activation

Examples of javax.activation.DataHandler.writeTo()


    URL oUrl = new URL(sFilePath);
   
    ByteArrayOutputStream oStrm = new ByteArrayOutputStream();
    DataHandler oHndlr = new DataHandler(oUrl);
    oHndlr.writeTo(oStrm);
    sRetVal = oStrm.toString(sEncoding);
    oStrm.close();

    return sRetVal;
  } // readfilestr
View Full Code Here


    IBindingFactory oIbf = BindingDirectory.getFactory(YSearchResponse.class);
    IUnmarshallingContext oUmc = oIbf.createUnmarshallingContext();

    ByteArrayOutputStream oOst = new ByteArrayOutputStream();
    DataHandler oHnd = new DataHandler(oUrl);
    oHnd.writeTo(oOst);
    ByteArrayInputStream oIst = new ByteArrayInputStream(oOst.toByteArray());
    oYsr = (YSearchResponse) oUmc.unmarshalDocument (oIst, "UTF8");   
    oIst.close();
    oOst.close();
  } catch (JiBXException jibxe) {
View Full Code Here

  private static void copyHTTPToFile (String sSource, String sTarget)
    throws MalformedURLException,IOException {
    URL oUrl = new URL(sSource);
    FileOutputStream oTrgt = new FileOutputStream(sTarget.substring(7));
    DataHandler oHndlr = new DataHandler(oUrl);
    oHndlr.writeTo(oTrgt);
    oTrgt.close();
  } // copyHTTPToFile

  // ---------------------------------------------------------------------------
View Full Code Here

      URL oUrl = new URL(sFilePath);

    if (user().equals("anonymous") || user().length()==0) {
        ByteArrayOutputStream oStrm = new ByteArrayOutputStream();
        DataHandler oHndlr = new DataHandler(oUrl);
        oHndlr.writeTo(oStrm);
        aRetVal = oStrm.toByteArray();
        oStrm.close();
      } else {
      if (null==oHttpCli) {
        oHttpCli = new DefaultHttpClient();
View Full Code Here

      URL oUrl = new URL(sFilePath);
    if (user().equals("anonymous") || user().length()==0) {
        ByteArrayOutputStream oStrm = new ByteArrayOutputStream();
        DataHandler oHndlr = new DataHandler(oUrl);
        oHndlr.writeTo(oStrm);
        sRetVal = oStrm.toString(sEncoding);
        oStrm.close();
    } else {
      if (null==oHttpCli) {       
        oHttpCli = new DefaultHttpClient();
View Full Code Here

                        this.put(name, text.getText());
                    } else if (type.equals(BYTEARRAY)) {
                        DataHandler dh = (DataHandler) text.getDataHandler();
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        try {
                            dh.writeTo(baos);
                            this.put(name, baos.toByteArray());
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
View Full Code Here

        if (omText.isBinary()) {
            // Stream the binary content
            DataHandler dh = (DataHandler)omText.getDataHandler();
            Base64EncodingWriterOutputStream out = new Base64EncodingWriterOutputStream(new ContentHandlerWriter(contentHandler));
            try {
                dh.writeTo(out);
                out.complete();
            } catch (IOException ex) {
                Throwable cause = ex.getCause();
                if (cause instanceof SAXException) {
                    throw (SAXException)ex.getCause();
View Full Code Here

        MessageContext msgCtx   = MessageContext.getCurrentMessageContext();
        Attachments attachment  = msgCtx.getAttachmentMap();
        DataHandler dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
    fos.flush();
    fos.close();
        System.out.println("Wrote SwA attachment to temp file : " + tempFile.getAbsolutePath());

        MessageContext outMsgCtx = msgCtx.getOperationContext().
View Full Code Here

        Attachments attachment = response.getAttachmentMap();
        dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
        fos.flush();
        fos.close();

        System.out.println("Saved response to file : " + tempFile.getAbsolutePath());
View Full Code Here

                handler.setCommandMap(AttachmentUtil.getCommandMap());
               
                writeHeaders(handler.getContentType(), a.getId(),
                             headers, writer);
                out.write(writer.getBuffer().toString().getBytes(encoding));
                handler.writeTo(out);
            }
        }
        StringWriter writer = new StringWriter();               
        writer.write("\r\n");
        writer.write("--");
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.