Java的IO可分為以下幾類。處理byte的類別有:
處理char的類別有:
處理檔案的類別有:

範例

/**
 * Programming Methodology Homework #2 Example.
 * Author: Shiuh-Sheng Yu
 * Date:   3/16/1998
 * Last updated date: 3/17/1998
 */
import java.io.*;
import java.util.*;
public class H2 {
    private static String nextToken(BufferedReader din) throws IOException {
        StringBuffer sb = new StringBuffer();
        int c;
        try {
            do {
                c = din.read();
            } while (c==' ' || c=='\n' || c=='\r' || c=='\t');
            while (c!=-1 && c!=' ' && c!='\n' && c!='\t' && c!='\r') {
                sb.append((char)c);
                c = din.read();
            }
        } catch (EOFException e) {
        }
        if (sb.length()==0) {
            return "";
        }
        return sb.toString();
    }

    private static Matrix readMatrix(BufferedReader din) throws MalMatrixException, IOException {
        String token = nextToken(din);
        int x, y;
        double[][] data;
        if (!token.equals("matrix")) {
            throw new MalMatrixException();
        }
        token = nextToken(din);
        try {
            x = Integer.parseInt(token);
        } catch (NumberFormatException eNum) {
            throw new MalMatrixException();
        }
        token = nextToken(din);
        try {
            y = Integer.parseInt(token);
        } catch (NumberFormatException eNum) {
            throw new MalMatrixException();
        }
        data = new double[x][y];
        for (int i=0; i