Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java 1.4: MalformedInputException is not thrown anymore?

Reply
Thread Tools

Java 1.4: MalformedInputException is not thrown anymore?

 
 
Dima
Guest
Posts: n/a
 
      07-14-2004
Hi,

In Java 1.3 if I read an invalid UTF-8 data I get
MalformedInputException.
In Java 1.4 I get character 65533 and no exception.

Why is what? Is it a bug? The new behaviour silently corrupts the data
instead of throwing an exception.

This is my test case:

import java.io.*;

public class test {

public static void main(String[] args)
throws Exception
{
int ch;
Reader r = new InputStreamReader(new FileInputStream(args[0]),
"UTF-8");
while((ch = r.read()) >= 0) {
System.out.println("char " + (char)ch + " " + (int)ch);
}
}
}

I put some Russian text in Cyrillic encoding and I try to read it as
UTF-8.

Java 1.3:
/cygdrive/d/prj/utf8/>java test test.txt
char t 116
char e 101
char s 115
char t 116
char : 58
Exception in thread "main" sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java: 85)
at java.io.InputStreamReader.convertInto(InputStreamR eader.java:132)
at java.io.InputStreamReader.fill(InputStreamReader.j ava:161)
at java.io.InputStreamReader.read(InputStreamReader.j ava:244)
at java.io.InputStreamReader.read(InputStreamReader.j ava:217)
at test.main(test.java:10)

Java 1.4:

/cygdrive/d/prj/utf8/>c:/j2sdk1.4.2_04/bin/java test test.txt
char t 116
char e 101
char s 115
char t 116
char : 58
char 32
char ? 65533
char ? 65533
char ? 65533
char ? 65533
char ? 65533
char ? 65533
char ? 65533
char 32
char
10
/cygdrive/d/prj/utf8/>


Thanks and best regards,
Dima.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'unreported exception java.io.IOException; must be caught or declared to be thrown Cassandra Java 0 10-08-2009 06:40 AM
Exception thrown & Failure in loading T2 native library db2jcct2 while connecting to db2/400 through java savita Java 1 12-30-2006 03:37 PM
Response.Redirect gens ThreadAbortException that's either not being caught or thrown a second time. Eric ASP .Net 1 08-19-2005 06:00 PM
SOAP Header Not Sent If Exception Thrown David Hayward via .NET 247 ASP .Net Web Services 0 05-23-2005 09:34 PM
exception thrown on one machine, but not another Adam C++ 3 01-13-2005 11:23 PM



Advertisments