views:

109

answers:

2

I have been trying to read a file in "cp037" encoding scheme using JAVA. I able to read a file in basic encoding schemes like UTF-8, UTF16 etc...After a bit of research on the internet i came to know that we need charset.jar or international version of JRE be installed to support extended encoding schemes. Can anyone send me a link for international version of JRE6 or JDK6. or is there any better way that i could read a file in cp037 encoding scheme.

P.S: cp037 is a character encoding scheme supported by IBM Mainframes. All i need is to display a file in windows, which is being generated on IBM Mainframes machine, using a java program.

Thanks in advance for your help... :-)

+1  A: 

After a bit of research on the internet i came to know that we need charset.jar or international version of JRE be installed to support extended encoding schemes.

Are you sure that this charset isn't included in the standard distribution though?

This code works fine for me on jdk 1.6.0_17 64bit (Windows):

Charset charset = Charset.forName("cp037");
BufferedReader br = new BufferedReader(new InputStreamReader(
    new FileInputStream(f), charset));

String line = null;
while ((line = br.readLine()) != null) {
    System.out.println("read line: " + line);
}
matt b
+1  A: 

I found this webpage for Java 5 (note, it might be different for Java 6). There is no special, separate "international" version of the JRE or JDK; however, the lib\charsets.jar may or may not be installed on your system depending on what your operating system supports.

Are you sure there is no charsets.jar in your JRE installation directory? On my system, it's under %JDK_HOME%\jre\lib. (Note: NOT under %JDK_HOME%\lib).

Search your system to see if you already have charsets.jar somewhere. (Note that it's called charsets.jar with an s, not charset.jar).

Jesper
you are right! it's charsets.jar. I dont have it in standard distribution. I could find i18n.jar, which supports extended character set. I have put that i18n.jar file in jre\lib but not working tough!
Reddy