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

[1490 byte] By [anaik100a] at [2007-11-26 14:30:09]
# 1
Try it with "US-ASCII" instead of "ASCII", as the docs state. I don't know if there's a difference, but that is the value specified for the java.newio.charset.Charset encoder.
ChuckBinga at 2007-7-8 2:24:46 > top of Java-index,Java Essentials,Java Programming...
# 2
US-ASCII does not help.
anaik100a at 2007-7-8 2:24:46 > top of Java-index,Java Essentials,Java Programming...
# 3
Possibly the MF data is incorrect.
ChuckBinga at 2007-7-8 2:24:46 > top of Java-index,Java Essentials,Java Programming...
# 4

> 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.

>

Not all EBCIDIC characters have ASCII equivalents and there are several EBCIDIC code pages - http://en.wikipedia.org/wiki/EBCDIC_8859. ASCII only uses bytes 0 to 0x7f but EBCIDIC can use 0 to 0xff.

So the questions are

1) What are the 'mismatch' characters?

2) Do you really have ASCII or is it an ISO-8859-x or other ASCII superset?

3) Which version of EBCDIC are you trying to convert to?

sabre150a at 2007-7-8 2:24:46 > top of Java-index,Java Essentials,Java Programming...
# 5
but i am using a tool which can transmit data from mainframe in ASCII and EBCIDIC.So is there any other algorithm using which i can do my conversion
anaik100a at 2007-7-8 2:24:46 > top of Java-index,Java Essentials,Java Programming...
# 6
It's not a question of 'another algorithm'.Which version of EBCDIC do you want? and which mapping do you want to use?You've already been asked these questions and you need to identify the answers.
ejpa at 2007-7-8 2:24:46 > top of Java-index,Java Essentials,Java Programming...
# 7
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=016601
sabre150a at 2007-7-8 2:24:46 > top of Java-index,Java Essentials,Java Programming...