This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Features new in Java 7 and the fly likes NIO and UTF-8 Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "NIO and UTF-8 Exception" Watch "NIO and UTF-8 Exception" New topic
Author

NIO and UTF-8 Exception

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

Whilst using NIO to read a small text file, I have come across an exception with the following message : input length = 1


When the program is run through Netbeans 7.4 on java 7 update 51 there is no exception.

It only appears when the program is run on the standalone JRE same version as above.

I have searched the internet and not been able to find a solution.


I am using charset UTF-8

Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3605
    
  14

You should change the code on line 43.

But seriously, posting your code would help.
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

The code runs as intended when run through the JRE provided with NetBeans. Java 7 Update 51
It throws exception when run on standalone JRE same version as above.
I have the exact same method instead using IO and it does not throw any exception.

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5147
    
  12

And can we have the stack trace as well?


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

I was able to find the solution which consists of a minor change to the charset.

The method now runs as intended through NetBeans or through standalone JRE.

Thank you for your attention in this matter Roel De Nijs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NIO and UTF-8 Exception
 
Similar Threads
Accessing java from Visual Basic
Length of the Socket Input Stream to Read 'OR' End of the Socket Stream
Encoding in Java file
multiple language support in one XML
NX: (Contractors) Character encoding