Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6203963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:00:27+00:00 2026-05-24T05:00:27+00:00

I have an input byte array which I would like to feed to the

  • 0

I have an input byte array which I would like to feed to the standard input of an external program (Process). Also, I would like to collect the output in a byte array.

What is the most elegant way to do this? PipedInputStream/PipedOutputStream? nio.channels.Pipe?

Sample code would be a plus because I can’t really figure out how to do this in a good way…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:00:28+00:00Added an answer on May 24, 2026 at 5:00 am

    Combining PipedInputStream with PipedOutputStream and Peter’s MultiOutputStream from another post here, you can get the following:

    final int CAPCITY = 4096;
    final int PIPE_SIZE = 4096;
    
    PipedOutputStream pout = new PipedOutputStream();
    ByteArrayOutputStream bout = new ByteArrayOutputStream(CAPACITY);
    MultiOutputStream multiOs= new MultiOutputStream(pout, bout);
    
    PipedInputStream is = new PipedInputStream(pout, PIPE_SIZE);
    

    Now, if you execute:

    byte[] bytes = new bytes[1024];
    multiOs.write(bytes, 0, 1024);
    

    You feed your PipedInputStream, optionally handing the reference over to another process, i.e. Java Thread. Simultaneoulsy, you write into a byte array, which can be queried by:

    bytes[] written = bout.toByteArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have byte array as input. I would like to convert that array to
I have input fields, which I process with AJAX and send it on another
Suppose i have input array byte A[50]; i have put three diffrent data types
The input data is a byte array which represents a h.264 frame. The frame
Currently I have Input: e.g., '123456789'.'+'.'987654321' Desired Pattern: Output: e.g., '123456789987654321' How can I
I have an input which is about 450 today, and it might increase in
I have a flash recorder which record user input and give me a file
I have to send the audio data in byte array obtain by recording from
I have (yet another) powershell query. I have an array in powershell which i
I have the following string that I would like to Huffman-encode and store efficiently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.