077b12f1039dceb830c2b83be8dcbd1b

An example that use BufferedInputStream and BufferedOutputStream for read and write a char.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * This example show how to read from the keyboard and write to the
 * monitor one char. ! This is only an example ! Use Reader and 
 * Writer sub-classes for working with characters.
 */

import java.io.*;

public class ReadAndWrite {

    public static void main(String[] args) {
       
        int ch = 0;
        BufferedInputStream keyboard = new BufferedInputStream(System.in);
        BufferedOutputStream monitor = new BufferedOutputStream(System.out);
       
        try {
            ch = keyboard.read();
            monitor.write(ch);
            monitor.flush();
        } catch(IOException e) {}
       
    }
}

Refactorings

No refactoring yet !

Your refactoring





Format Copy from initial code

or Cancel