I am trying to convert EBCDIC file to ASCII using following code :
InputStreamReader rdr = new InputStreamReader(new FileInputStream(<your file>),java.nio.Charset.forName("ibm500"));
while((String line = rdr.readLine()) != null) {
System.out.println(line);
I am trying to find a sample file in EBCDIC format to send it as an input to this program. Can anyone please point me to a sample file. can't find anything online.
You can use the iconv
utility on Unix to convert between character encodings. It is also available for Windows (it's an optional package you can install in Cygwin, for example). You can also use the dd
command to convert character encodings.
dd if=ascii.txt of=ebcdic.txt conv=ebcdic
You should also be able to use Java to do the conversion in the other direction from the way you're currently doing it. Just read the file as ASCII and write it as EBCDIC.