PrintWriter stdout = new PrintWriter(System.in);
File file = new File("filename");
FileWriter writer = new FileWriter(file);
PrintWriter fileout = new PrintWriter(writer);
InputStreamReader reader = new InputStreamReader(System.in);
BufferdReader stdin = new BufferedReader(reader);
File file = new File("filename");
try {
FileReader reader = new FileReader(file);
BufferedReader filein = new BufferedReader(reader);
catch (FileNotFoundException fnfe) {
stdout.println("ERROR: File " + filename + " not found!");
// handle exception by reprompting or quiting
}
| Class Summary | |||||
|---|---|---|---|---|---|
| Readers | Input Source |
Output Destination |
Writers | ||
| Printers | PrintStream | PrintWriter | |||
| Buffers | Buffered Reader | BufferedWriter | |||
| Reader | Writer | ||||
| Console | InputStreamReader | InputStream | OutputStream | OutputStreamWriter | |
| Files | FileReader | File | FileWriter | ||

| Class | Commonly Used Methods and Constructors | ||||
|---|---|---|---|---|---|
| Return Type | Method Name | Parameter List | Throws Clause | ||
| Reader | |||||
| Reader | () | ||||
| void | close | () | throws IOException | ||
| boolean | ready | () | throws IOException | ||
| void | reset | () | throws IOException | ||
| Writer | |||||
| Writer | () | ||||
| void | close | () | throws IOException | ||
| void | flush | () | throws IOException | ||
| BufferedReader extends Reader | |||||
| BufferedReader | (Reader r) | ||||
| String | readLine | () | throws IOException | ||
| BufferedWriter extends Writer | |||||
| BufferedWriter | (Writer w) | ||||
| void | newLine | () | throws IOException | ||
| PrintWriter extends Writer | |||||
| PrintWriter | (OutputStream) | ||||
| PrintWriter | (Writer) | ||||
| void | (String s) | ||||
| void | println | (String s) | |||
| PrintStream extends OutputStream | |||||
| PrintStream | (OutputStream os) | ||||
| void | () | ||||
| void | println | () | |||
| InputStream | |||||
| InputStream | () | ||||
| OutputStream | |||||
| OutputStream | () | ||||
| InputStreamReader extends Reader | |||||
| InputStreamReader | (InputStream is) | ||||
| OutputStreamWriter extends Writer | |||||
| OutputStreamWriter | (OutputStream os) | ||||
| File | |||||
| File | (String filename) | ||||
| boolean | exists | () | |||
| boolean | canRead | () | |||
| boolean | canWrite | () | |||
| boolean | isFile | () | |||
| boolean | isDirectory | () | |||
| FileReader extends InputStreamReader | |||||
| FileReader | (File file) | throws FileNotFoundException | |||
| FileWriter extends OutputStreamWriter | |||||
| FileWriter | (File file) | ||||
| StringTokenizer | |||||
| StringTokenizer | (String line, String delimiter) | ||||
| int | countTokens | () | |||
| boolean | hasMoreTokens | () | |||
| String | nextToken | () | throws NoSuchElementException | ||
| Integer extends Number | |||||
| String | parseInt | (String number) | throws NumberFormatException | ||