Converter.java

import java.io.*;
public class Converter {
  String fromEnc;
  String toEnc;
  public Converter(String fromEnc, String toEnc) {
    this.fromEnc = fromEnc;
    this.toEnc = toEnc;
  }
  public void convert(InputStream in, OutputStream out)
    throws IOException {
    InputStreamReader reader = new InputStreamReader(in, fromEnc);
    OutputStreamWriter writer = new OutputStreamWriter(out, toEnc);
    char[] tampon = new char[256];
    int nbLus;
    while ((nbLus=reader.read(tampon))!=-1) {
      writer.write(tampon,0,nbLus);
    }
    writer.close();
    reader.close();
  }
  public static void main(String[] args) throws IOException {
    Converter conv = new Converter("8859_1","Cp037");
    conv.convert(System.in,System.out);
  }
}