Skip to main content

java.lang.IllegalArgumentException: Malformed \uxxxx encoding

I was getting this exception during build while running ant. Googling didn't help much and I was flummoxed because the same code was running fine till now.

My code reads a text file and does some operations on the basis of values read. It was only when I saw the text files I understood the error. I had copied the text in wordpad and saved it as .txt file. Wordpad had put lot of formatting information before and after the content. Also there was "\par" after every line, which was giving this error.

So moral of the story: if you get this exception check your properties file (or any other file that your code might be reading.)

Comments

Jesus M Movilla said…
I have the same problem but apparently the text file is fine, how can I check if there are some undesirable characters in it?

Thanks a lot!
Waterfox said…
Try to open the file in vim editor or any other UTF-8 enabled text editor.
Jesus M Movilla said…
Solved!
It was a "\u" in a property value...

Thanks!
GIRISH said…
Hi,
i'm Getting the same while loading the file...
here is the code:
FileInputStream MyInputStream = new FileInputStream(new File("Defaultprop.pref"));
myProps.load(MyInputStream);

please Help Me Out With This..

Thanks a Lot
GIRISH said…
Hi,
Even I'm gettin same error while loadin the file... here is the code:
FileInputStream MyInputStream = new FileInputStream(new File("Defaultprop.pref"));

myProps.load( new FileInputStream("Defaultprop.pref"));

Please Help out to get rid of this ;0
Waterfox said…
The same advice that I gave to previous question. Please check your .pref file in vim or any other UTF-8 enabled text editor to see if there is any unwanted characters in the file.
Luke said…
Thanks for posting this. Saved me a ton of time. Had this problem intermittently in a build file. The build.properties file would have been one of the last places I'd have thought to look. Ended up being an unescaped "\" in my build.properties file.

Popular posts from this blog

How I converted a table in an email to a graph on a website? Hint: Azure Functions and Logic App

This mini-project started as a necessity.  I get an email like this everyday, which gives daily numbers for different metrics. The problem with such an email is that it is difficult to keep track of or gauge the rate of growth of these metrics. If you want to know how what the previous day's numbers were you need to go to the previous day's email.  The better option any day is to have a graph that shows the values of the metrics every day. Something like this: With this goal I set out to make this system but with as less coding and expenses as possible.  First obvious step in the process was to get hold of the email and extract its text. The easiest way to do this is to use Azure Logic App.  Here is what my logic app looks like: When any new email arrives in my Outlook 365 account, with a subject that contains "System usage Stats as on", it passes the body of the email to an Azure function named 'EmailTextCleanerFunction' (code below), whose job is to clean an...

Changing Eclipse Workspace Directory

Recently I moved my entire Eclipse installation directory but the workspace was still getting created in the older location only. And worst there was no option to select the Workspace directory in the Window->Options->Workspace menu. To change the workspace location in Eclipse do this. Goto ECLIPSE_HOME\configuration\.settings directory, edit the org.eclipse.ui.ide.prefs file and change the RECENT_WORKSPACES value to the desired location. If you want that Eclipse prompts you to select workspace when you start it, change the SHOW_WORKSPACE_SELECTION_DIALOG value to true. And you are done!

Hands on review: Yahoo! Mail app for Windows 8

Before you start mocking me for using Yahoo! Mail, let me explain that this is NOT my primary mail account and I use Gmail and Outlook.com for my daily use. Yes, this Yahoo! account was once my daily haunt but that was during college days and those days are long gone. I don't use Yahoo! Mail much but still there are some group subscriptions and I just log in once in a while to see what's happening in those forgotten groups. And due to this reason, I have always kept track of changes in Yahoo! Mail and the fact is that you can blame them for everything but not really lack of trying. Though most of those tries just ended up cluttering the UI and adding somewhat needless features. However, now we hear that new CEO Marissa Mayer is focusing once again on the mail and first major product to come out is Yahoo! Mail app for Windows 8. So how is it? The Login screen is pretty neat and purple background with an envelope watermark is very pleasing, very Yahoo!. However why ...