This can be useful when migrating data from a legacy database (ex. Clipper, dBase) to newer DBMS (ex. mySQL, Sybase).
import java.io.*;
public class OemToAnsi {
public static void main(String args[]) throws Exception{
if (args.length != 2) {
System.out.println(
"Usage : java OemToAnsi inputdosfile outputansifile"
);
System.out.println(
" note : codepage input Cp850 codepage output Cp1252"
);
System.exit(1);
}
// input
FileInputStream fis = new FileInputStream(args[0]);
BufferedReader r =
new BufferedReader(new InputStreamReader(fis, "Cp850"));
// output
FileOutputStream fos = new FileOutputStream(args[1]);
Writer w =
new BufferedWriter(new OutputStreamWriter(fos, "Cp1252"));
String oemString = "";
while ( (oemString= r.readLine()) != null) {
w.write(oemString);
w.flush();
}
w.close();
r.close();
System.exit(0);
}
}Written and compiled by Réal Gagnon ©1998-2006
[ home ]