Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

Posts Tagged ‘windows

java.lang.IllegalArgumentException: Malformed \uxxxx encoding

with 11 comments

The above error is cause by the baclslash “\” that use in Windows.

I demostrate the error in this simple example.
The example is going to get the File object that being instancial by Spring to do further process.

The java code is looks like this:

public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] {
		BeanFactory factory = (BeanFactory) context;
		final String myFileBeanName = "myFile";
		File file = (File) factory.getBean(myFileBeanName);

The applicationContext.xml for Spring:

<bean id="myFile" class="">

In the properties file, the $file.path is defined as file.path=D:\data\test\my-spring-file.txt.

When I trying to run the java code, it returns me

Exception in thread "main" java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
at java.util.Properties.loadConvert(Unknown Source)
at java.util.Properties.load(Unknown Source)

So, I change the $file.path to file.path=D:\\data\\test\\my-spring-file.txt, and its work fine to me!


Written by Alfred

November 13, 2008 at 15:20

Posted in Java, Spring

Tagged with , ,