I/O streams in java

i/o streams in java,Input/Output Streams in Core Java,Java I/O Tutorial

File Copy Tutorial Java

File Copy Tutorial Java: File copying operation, in Java, can be done in 5 steps broadly. Open the source file in read mode (say, using FileInputStream constructor) Open the destination file in write mode (say, using FileOutputStream constructor) Read data from the source file (say, using read() method) Write data to the destination file (say, …

File Copy Tutorial Java Read More »

Chaining Streams Java

Chaining Streams Java Java comes with low-level byte streams and high-level byte streams and similarly low-level and high-level character streams. Sub classes of FilterInputStream and FilterOutputStream are known as high-level streams. There are four high-level streams on input streams side – LineNumberInputStream, DataInputStream, BufferedInputStream and PushbackInputStream. The job of high-level streams is to add extra …

Chaining Streams Java Read More »

PipedInputStream PipedOutputStream

PipedInputStream PipedOutputStream – Transferring Data between Processes What is pipe? A pipe is a transferring channel though which data flows. Pipe is a conduit to send data of an output stream to an input stream. Generally, a thread connected to PipedOutputStream sends data to another thread connected to PipedInputStream. To transfer data between two running …

PipedInputStream PipedOutputStream Read More »

Keyboard Input Scanner Java

The Scanner class is placed in java.util package (not in java.io) to facilitate to take input for DS (Data structure) elements. The advantage of Scanner class is parsing is not required for keyboard input data which is required with DataInputStream (as in KeyboardReading1.java) and BufferedReader (as in KeyboardReading2.java). Scanner class can not only read from …

Keyboard Input Scanner Java Read More »

Keyboard Input BufferedReader Java

The previous program (KeyboardReading1.java) of reading keyboard input, using DataInputStream, raises a deprecation warning. To overcome this, in the following program, the readLine() method of BufferedReader is used. Example on Keyboard Input BufferedReader Java The following program takes input from keyboard to fill the array elements. The elements and their average are printed. import java.io.*; …

Keyboard Input BufferedReader Java Read More »

Keyboard Input DataInputStream

In keyboard reading, three programs are given using DataInputStream, BufferedReader and Scanner. Of all, using java.util.Scanner is the easier and includes many methods to check the input data is valid to read. Example on Keyboard Input DataInputStream Following program uses readLine() method of DataInputStream to read data from the keyboard. import java.io.*; public class KeyboardReading1 …

Keyboard Input DataInputStream Read More »