How to write to file in Java - FileOutputStream - Mkyong.com.
The java.io.OutputStream.write(int b) method writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
That is why it is called a DataOutputStream - because you can write int, long, float and double values to the OutputStream, and not just raw bytes. Often you will use the Java DataOutputStream together with a Java DataInputStream. You use the DataOutputStream to write the data to e.g. a file, and then use the DataInputStream to read the data.
Java FileOutputStream. FileOutputStream is an output stream for writing data to a File or to a FileDescriptor.FileOutputStream is a subclass of OutputStream, which accepts output bytes and sends them to some sink.In case of FileOutputStream, the sink is a file object. Java FileOutputStream constructors. These are FileOutputStream constructors.
A data output stream lets an application write primitive Java data types to an output stream in a portable way. An application can then use a data input stream to read the data back in.
Java DataOutputStream Class. Java DataOutputStream class allows an application to write primitive Java data types to the output stream in a machine-independent way. Java application generally uses the data output stream to write data that can later be read by a data input stream.
The Java OutputStreamWriter class, java.io.OutputStreamWriter, is intended to wrap an Java OutputStream and thereby turning the byte based output stream into a character based Writer.The Java OutputStreamWriter can also wrap any subclass of OutputStream. The Java OutputStreamWriter is useful if you need to write characters to a file, encoded as e.g. UTF-8 or UTF-16.
Java ByteArrayOutputStream Class. Java ByteArrayOutputStream class is used to write common data into multiple files. In this stream, the data is written into a byte array which can be written to multiple streams later. The ByteArrayOutputStream holds a copy of data and forwards it to multiple streams.