Here is the basic program with a "translate" method, and a sample
"main" method to use it with FileInputStream and FileOutputStream
objects.  The "main" method takes two arguments: the names of an input
file and an output file, and it writes the output file as a copy of
the input file translated into "B language", where all consonants are
translated to the letter 'b'.

import java.io.*;

class Translate {

    public static void translate(InputStream in, OutputStream out,
                                 String from, String to)
	throws IOException
    {
        if (from.length() != to.length())
	    throw new IOException("from and to must be same length");

	int ch, i;

	while ((ch = in.read()) != -1) {
	    if ((i = from.indexOf(ch)) != -1)
		out.write(to.charAt(i));
	    else
		out.write(ch);
	}
    }

    public static void main(String args[]) {
	if (args.length != 0 && args.length != 2)
	    error("must provide name of input and output files");

	try {
	    InputStream in;
	    OutputStream out;

	    if (args.length == 2) {
		in = new FileInputStream(args[0]);
		out = new FileOutputStream(args[1]);
	    } else {
		in = System.in;
		out = System.out;
	    }

	    translate(in, out,
	              "CDFGHJKLMNPQRSTVWXYZcdfghjklmnpqrstvwxyz",
	              "BBBBBBBBBBBBBBBBBBBBbbbbbbbbbbbbbbbbbbbb");
	    // note: the above does not properly handle cases where
	    // the letter 'y' has the role of a vowel
	} catch (IOException e) {
	    error("I/O Exception: " + e);
	}
    }

    public static void error(String err) {
	System.err.println("Translate: " + err);
	System.exit(1); // non-zero argument means "not good"
    }
}
