I wrote a simple java program to convert EBCDIC to ASCII. It's not working correctly. Here is what I did
Step 1: Convert ASCII file to EBCDIC using the following command :
dd if=sampleInput.txt of=ebcdic.txt conv=ebcdic
sampleInput.txt has following line :
input 12 12
Step 1: generated ebcdic.txt
Now, wrote following java program to convert ebcdic to ascii
public class CoboDataFilelReaderTest {
public static void main(String[] args) throws IOException {
int line;
InputStreamReader rdr = new InputStreamReader(new FileInputStream("/Users/rr/Documents/workspace/EBCDIC_TO_ASCII/ebcdic.txt"), java.nio.charset.Charset.forName("ibm500"));
while((line = rdr.read()) != -1) {
System.out.println(line);
}
}
}
It gave me wrong output, the output looks something like this :
115
97
109
112
108
101
32
49
50
32
49
50
Please let me know what I am doing wrong and how to fix it.