java.io Package provides for system input and output through data streams, serialization and the file system. This tutorial is an overview of Java I/O and all the classes in the java.io package. And explains how to handle file management in java.
Basic requirements to create files in java.
What's your format for storing or transmitting data? Will you be using text or binary data?
If you use binary data, such as integers or doubles, then use the InputStream and OutputStream classes.
If you are using text data, then the Reader and Writer classes are right.
Do you want random access to records? Random access allows you to go anywhere within a file and be able to treat the file as if it were a collection of records.
The RandomAccessFile class permits random access. The data is stored in binary format. Using random access files improves performance and efficiency.
Are you inputting or outputting the attributes of an object? If the data itself is an object, then use the ObjectInputStream and ObjectOutputStream classes.
What is the source of your data? What will be consuming your output data, that is, acting as a sink? You can input or output your data in a number of ways: sockets, files, strings, and arrays of characters.
Any of these can be a source for an InputStream or Reader or a sink for an OutputStream or Writer.
Do you need filtering for your data? There are a couple ways to filter data.
Buffering is one filtering method. Instead of going back to the operating system for each byte, you can use an object to provide a buffer.
Checksumming is another filtering method. As you are reading or writing a stream, you might want to compute a checksum on it. A checksum is a value you can use later on to make sure the stream was transmitted properly.
A data record is a collection of more than one element, such as names or addresses. There are three ways to store data records: