Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the responsive-lightbox domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wp-includes/functions.php on line 6114
I/O in java - Testingpool

I/O in java

Java I/O is an API which is used to read and write data (Input and Output) and it is located in package called java.io.The Java IO package is primarily focused on input and output to files, network streams, internal memory buffers etc. or in sample terms we can say it perform file handling in java.

Java I/O API is mostly concerned for reading the raw data from from a source and writing the raw data to a destination. What could be these source and destination?

  • Files
  • pipes
  • Network connection
  • System.in, System.out, System.error
  • In memory-Buffers (e.g. arrays)

Streams:

A stream is conceptually endless flow of data. It could be in byte form or character form. We can either read from a Stream and write to a Stream

Program needs InputStream or Reader to read the data from source and requires OutputStream or writer to write the data to some destination.

In java, we mostly see 3 kinds of stream as mentioned below.

  1. System.in: standard input stream (read data from console)
  2. System.out: standard output stream (Write data to console)
  3. System.err: standard error stream (Write data to console)

These streams are attached with the console. Let’s understand these with examples.

Read input from console.
int i = System.in.read();

Write output and error to Console.
System.out.println(“Output”);
System.err.println(“Error”);

I/O overview

Ask Question
If you have any question, you can go to menu ‘Features -> Q&A forum-> Ask Question’.Select the desired category and post your question.

 

Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...

1 Response

  1. August 8, 2015

    […] In this post , we will look at what is InputStream and OutputStream in java? In the previous post, we have seen I/O overview. […]