How to simulate file IO in Java?
How to create an imitation Java io. Class of file w.r.t: mockfile File read / write? I use my own method everywhere instead of the new FileInputStream (...) And a new fileoutputstream (...), So this part is OK (I always delegate to the corresponding stream) The non - trivila part is the implementation of my mockfileinputstream and mockfileoutputstream in more complex cases
No problem. When I write a file for the first time and then read it, I can simply use bytearrayoutputstream and so on This is simple, but by interleaving reading and writing, it doesn't work properly A better idea than writing my own version of bytearrayoutputstream?
Solution
I will use a real file and a real FileInputStream and fileoutputstream Otherwise you're just practicing testing code: it's really boring