Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final LSOutput output; // XML stuff initialized elsewhere
- final LSSerializer serializer;
- final Document doc;
- // ...
- PostMethod post; // HttpClient post request
- final PipedOutputStream source = new PipedOutputStream();
- PipedInputStream sink = new PipedInputStream(source);
- // ...
- executor.execute(new Runnable() {
- public void run() {
- output.setByteStream(source);
- serializer.write(doc, output);
- try {
- source.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }});
- post.setRequestEntity(new InputStreamRequestEntity(sink));
- int status = httpClient.executeMethod(post);
- post.setRequestEntity(new RequestEntity()
- {
- public long getContentLength()
- {
- return 0-1;
- }
- public String getContentType()
- {
- return "text/xml";
- }
- public boolean isRepeatable()
- {
- return false;
- }
- public void writeRequest(OutputStream out) throws IOException
- {
- output.setByteStream(out);
- serializer.write(doc, output);
- }
- });
- import java.io.PipedInputStream;
- import java.io.PipedOutputStream;
- import com.jcraft.jsch.Channel;
- Channel channel;
- PipedInputStream channelInputStream = new PipedInputStream();
- PipedOutputStream channelOutputStream = new PipedOutputStream();
- channel.setInputStream(new PipedInputStream(this.channelOutputStream));
- channel.setOutputStream(new PipedOutputStream(this.channelInputStream));
- channel.connect();
- // Write to channelInputStream
- // Read from channelInputStream
- channel.disconnect();
Add Comment
Please, Sign In to add comment