ASCII to EBCIDIC conversion error
We are have some historical data in ASCII format. We want to insert this data into our system in EBCIDIC format. I am trying to write a code to convert ASCII data to EBCIDIC data
Below is my logic
import java.io.*;
public class DcollType {
static String readInput() {
StringBuffer buffer = new StringBuffer();
try {
FileInputStream fis = new FileInputStream("ASCII.txt");
InputStreamReader isr = new InputStreamReader(fis, "ASCII") ;
Reader in = new BufferedReader(isr);
int ch;
while ((ch = in.read()) > -1) {
buffer.append((char)ch);
}
in.close();
return buffer.toString();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
static void writeOutput(String str) {
try {
FileOutputStream fos = new FileOutputStream("ASCII_EBCIDIC.bin");;
Writer out = new OutputStreamWriter(fos, "Cp1047" );
out.write(str);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args){
String inputstr=readInput();
writeOutput(inputstr);
}
}
This data gets produced from mainframe. the mainframe transmitted a sample file one in ASCII and another in EBCIDIC.
I used my program and converted the ASCII file to EBCIDIC. When i compared with the mainframe EBCIDIC file, there is a mismatch.
Can anybody please advise

