Code example for InputStreamEntity

Methods: setContentEncodingsetContentType

0
            ByteArrayOutputStream out = new ByteArrayOutputStream() ;
            Model model = ModelFactory.createModelForGraph(graph) ;
            model.write(out, Lang.RDFXML.getName()); //model.write(out, WebContent.langNTriples) ;
            byte[] bytes = out.toByteArray() ;
            ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()) ;
            InputStreamEntity reqEntity = new InputStreamEntity(in, bytes.length) ;
            reqEntity.setContentType(Lang.RDFXML.getContentType().getContentType()); //reqEntity.setContentType(WebContent.contentTypeNTriples) ;
            reqEntity.setContentEncoding("UTF-8") ;
            HttpEntity entity = reqEntity ;
            return entity;
            //((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ; 
 
        /* 
        ContentProducer producer = new ContentProducer() { 
            @Override 
            public void writeTo(OutputStream out) throws IOException { 
                RDFDataMgr.write(out, graph, sendLang) ; 
            } 
        } ; 
         
        EntityTemplate entity = new EntityTemplate(producer) ;