BufferedInputStream and BufferedOutputStream in java

BufferedInputStream and BufferedOutputStream used an internal buffer to store date for read and write operations. Commonly used constructors of BufferedInputStream: 1. BufferedInputStream(InputStream in) Creates a BufferedInputStream and saves its argument, the input stream in, for later use. 2. BufferedInputStream(InputStream in, int size) Creates a BufferedInputStream with the specified buffer size, and saves its argument, the input stream in, for later use. Example: BufferedInputStreamExample.java import java.io.BufferedInputStream; … Read more

Categories IO

DataInputStream and DataOutputStream in java

DataInputStream: DataInputStream used to read primitive data types from an input source. Commonly used constructors of DataInputStream: DataInputStream(InputStream in) Creates a DataInputStream that uses the specified underlying InputStream. Commonly used methods of DataInputStream: public String readLine() throws IOException Reads the next line of text from the input stream. It reads successive bytes, converting each byte separately into … Read more

Categories IO

Byte Streams in java

Byte Streams in java: Programs use byte streams to perform input and output of 8-bit bytes. All byte stream classes are descended from InputStream and OutputStream. Always close the files to avoid serious resource leaks. Byte streams should only be used for the most primitive I/O. It represents a kind of low-level I/O so you should avoid in case complicated data types like … Read more

Categories IO

FileInputStream and FileOutputStream in java

FileInputStream: FileInputStream stream is used for reading data from the files. Commonly used constructors of FileInputStream: 1. FileInputStream(File file) Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system. 2. FileInputStream(String name) Creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file … Read more

Categories IO