-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.2, 1.2.0
-
generic, x86, sparc
-
generic, solaris_8, windows_95
Name: rm29839 Date: 05/21/98
ISO2022CN_CNS & ISO2022CN_GB is not supported in
the BufferedReader class.
It is Ok for BufferedWriter.
That means that you could not read back what you write
using the above 2 charset encoding.
Below is the ISO2022 file uses to generate a File
with the specified encoding.
import java.io.*;
public class ISO2022 {
public static void main (String args[])
{
String m_encoding="ISO2022CN_GB";
String output_text="key in some chinese text here «f¿Â¨pªü";
File m_file = new File ("output.txt");
try {
FileOutputStream oStream = new FileOutputStream(m_file);
OutputStreamWriter encode_writer = new OutputStreamWriter( oStream, m_encoding);
BufferedWriter b_writer = new BufferedWriter(encode_writer);
b_writer.write (output_text, 0, output_text.length());
b_writer.flush();
}
catch (IOException ie)
{
System.out.println ("Encoding not supported!!!!!");
}
} //main
} // iso2022
Below is the ISOreader file which I use to read
back what I encode in "output.txt". But it throws an Exception.
mport java.io.*;
public class ISOreader{
public static void main (String args[])
{
String m_encoding="ISO2022CN_CNS";
File m_file = new File ("output.txt");
FileInputStream inStream ;
InputStreamReader encode_reader;
BufferedReader b_reader ;
char [] cbuf =new char[100];
String readtext;
try {
inStream = new FileInputStream(m_file);
encode_reader = new InputStreamReader( inStream, m_encoding);
b_reader = new BufferedReader(encode_reader);
if(b_reader .ready())
{
// readtext=b_reader.readLine(cbuf,0,50 );
b_reader.read(cbuf,0,50 );
readtext=new String(cbuf);
System.out.println( "the file contains : "+readtext);
}
if (b_reader !=null)
b_reader.close();
if (encode_reader !=null)
encode_reader.close();
if (inStream != null)
inStream.close();
}
catch (IOException ie)
{
System.out.println ("Encoding not supported!!!!!");
}
} //main
} // iso2022
(Review ID: 28804)
======================================================================
ISO2022CN_CNS & ISO2022CN_GB is not supported in
the BufferedReader class.
It is Ok for BufferedWriter.
That means that you could not read back what you write
using the above 2 charset encoding.
Below is the ISO2022 file uses to generate a File
with the specified encoding.
import java.io.*;
public class ISO2022 {
public static void main (String args[])
{
String m_encoding="ISO2022CN_GB";
String output_text="key in some chinese text here «f¿Â¨pªü";
File m_file = new File ("output.txt");
try {
FileOutputStream oStream = new FileOutputStream(m_file);
OutputStreamWriter encode_writer = new OutputStreamWriter( oStream, m_encoding);
BufferedWriter b_writer = new BufferedWriter(encode_writer);
b_writer.write (output_text, 0, output_text.length());
b_writer.flush();
}
catch (IOException ie)
{
System.out.println ("Encoding not supported!!!!!");
}
} //main
} // iso2022
Below is the ISOreader file which I use to read
back what I encode in "output.txt". But it throws an Exception.
mport java.io.*;
public class ISOreader{
public static void main (String args[])
{
String m_encoding="ISO2022CN_CNS";
File m_file = new File ("output.txt");
FileInputStream inStream ;
InputStreamReader encode_reader;
BufferedReader b_reader ;
char [] cbuf =new char[100];
String readtext;
try {
inStream = new FileInputStream(m_file);
encode_reader = new InputStreamReader( inStream, m_encoding);
b_reader = new BufferedReader(encode_reader);
if(b_reader .ready())
{
// readtext=b_reader.readLine(cbuf,0,50 );
b_reader.read(cbuf,0,50 );
readtext=new String(cbuf);
System.out.println( "the file contains : "+readtext);
}
if (b_reader !=null)
b_reader.close();
if (encode_reader !=null)
encode_reader.close();
if (inStream != null)
inStream.close();
}
catch (IOException ie)
{
System.out.println ("Encoding not supported!!!!!");
}
} //main
} // iso2022
(Review ID: 28804)
======================================================================
- duplicates
-
JDK-4195985 new String( bvar , "ISO2022CN_GB"); returns exception
-
- Closed
-
-
JDK-4779029 Need feature complete NIO ISO-2022-CN-* coders (encode & decode)
-
- Resolved
-
- relates to
-
JDK-4296969 Incorrect behaviours of several character converters
-
- Closed
-