The sample files are in io.zip
Use the Console class so end-users can keep their password hidden from people near their computer screen.
Use input and output to make an echo machine:
Allow the machine to shut itself off.
If your application can know the exact length of the byte array it needs to read in, the code is relatively simple.
To read in an entire file, read in until the end-of-file (EOF) marker, negative 1 (-1). To do this, call the constructor for a file input stream.
If you know the file to input or output is not binary but contains characters, use an instance of FileReader, which works with Unicode and supports all the major human languages, including Chinese, Japanese, and Arabic.
This version has a BufferedReader, which is efficient. Without buffering, each invocation of read() or readLine() could cause bytes to be read from the file, converted into characters, and then returned, which can be very inefficient. Buffering is analogous to putting groceries in a bag, instead of carrying many small items one-by-one.
You can also write a Unicode file from lines the user types at the console: