title: Testing outputstream.write(<String>) without creating a file
body: <p>I am testing a output stream in java something like below.</p>
  
  <pre><code>    Writer outputStream = getOutputStream(fileName);
      if(outputStream != null) {
          try {
              outputStream.write(inputText);
          }
          finally {
              outputStream.close();
          }
      }
      else {
          throw new IOException("Output stream is null");
      }
  </code></pre>
  
  <p>I am write a mockito test as below</p>
  
  <pre><code>public void testFileWrite() throws IOException {
      when(testObj.getOutputStream(outputFileNameValidValue)).thenReturn(outputStreamMock);
      doNothing().when(outputStreamMock).write(Matchers.anyString());
      doNothing().when(bufferedReaderMock).close();
  
      testObj.write(outputFileNameValidValue, reveredFileInput);
  
      verify(outputStreamMock).write(Matchers.anyString());
      verify(outputStreamMock).close();
  }
  </code></pre>
  
  <p>The problem is when you create <code>OutputStreamWriter(new FileOutputStream(filename))</code> a physical file on the disk is created. </p>
  
  <p>Can we test <code>Outputstream.write</code> without actually writing a file on the disk?</p>
  
  <p>Thanks
  Anand</p>