by Dinesh Thakur Category: Stream

System.out.println() and System.out.print() are only used method for output on console. But there is a class PrintStream a drived class of OutputStream having a implemented method write(), it can be used to write to the console. The simplest form of write() is :

                                            void write (int byteValue)

The method writes to the stream in byte format by byte Value. The byte Value is declared as an integer but only low-order eight bits are written.

 

Example:

 

class DataWrite

{

public static void main(String args[])

{

int x;

x = 'A';

System.out.write(x);

System.out.write('\t');

x= 'p' ;

System.out.write(x);

System.out.write('\n');

}

}

Output:

Writing to Console Output



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content





Popular Article