Reading Console Input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Reading Characters from Console:
int read( ) throws IOException
// Use a BufferedReader to read characters from the console. import java.io.*; public class BRRead { public static void main(String args[]) throws IOException { char c; // Create a BufferedReader using System.in BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter characters, 'q' to quit."); // read characters do { c = (char) br.read(); System.out.println(c); } while(c != 'q'); } }
Reading Strings from Console:
String readLine( ) throws IOException
Writing Console Output:
void write(int byteval)
Reading and Writing Files:
FileInputStream:
InputStream f = new FileInputStream("C:/java/hello");
File f = new File("C:/java/hello"); InputStream f = new FileInputStream(f);
FileOutputStream:
OutputStream f = new FileOutputStream("C:/java/hello")
File f = new File("C:/java/hello"); OutputStream f = new FileOutputStream(f);