title: Java: common interface to InputStream and OutputStream
body: <p>This question is related (in some way) with <a href="https://stackoverflow.com/questions/14715473/share-stdfstream-or-stdstringstream-trough-stdiostream">this one</a>.</p>
  
  <p>Basically, I want to make a function, like this:</p>
  
  <pre><code>public InputOutputStream func()
  {
      if (condition)
      {
          // open a file stream and convert to InputOutputStream 
      }
      else
      {
          // make an InputOutputStream from string
      }
  }
  </code></pre>
  
  <p>Several questions arise:</p>
  
  <ul>
  <li>I can't find anywhere class like <code>InputOutputStream</code>. It's only <code>InputStream</code> and <code>OutputStream</code> and its variations (like <code>InputDataStream</code>, <code>OutputDataStream</code>, etc). Is there one? I need a stream which supports both read and write operations.</li>
  <li>How can I make an <code>InputOutputStream</code> from file?</li>
  <li>How can I make an <code>InputOutputStream</code> from string?</li>
  </ul>
  
  <p>For C++ <code>InputOutputStream</code> is a <code>std::iostream</code>. And I can convert <code>std::fstream</code> or <code>std::stringstream</code> to it without any problems. Is it reachable in Java?</p>
  
  <p>Thanks.</p>