This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am reading an XML file using FileInputStream and contents are sent to an unmarshaller method that accepts only FileInputStream. We have recently encountereda problem whereby the ampersnad character is not accpetable to the marshaller. My idea was to create a method that reads the file, replaces the ampersand character and writes back the contents to FileInputStream which is used by the unmarsahller.
The issue is that I have not found the way to write to FileInput Stream. The following is the code I am using for testing purposes:
Indeed, it's not possible to write to an InputStream. This demonstrates the advantages of not using specific classes -like FileInputStream- in public interfaces. If the API was using the InputStream interface instead, it would be easy to filter the stream.