What is the purpose of the `ByteArrayInputStream` class in Java?
The `ByteArrayInputStream` is used to read a byte array and write the data to a file in a byte-oriented stream.
You're partially correct. While `ByteArrayInputStream` reads from a byte array, it does not write data to a file. For writing, you would use `ByteArrayOutputStream`.
Can you explain how `ByteArrayInputStream` reads from memory rather than directly from a file?