directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vitali Baumtrok <>
Subject Issue with file loading under Windows (LDAP API 1.0.0-M10)
Date Wed, 22 Feb 2012 13:35:30 GMT
The method  
Class<?>): byte[]
returns zero bytes under Windows if the path to the class contains at  
least one space character. Because of that the  
LdapContext, clazz: Class<?>) doesn't work properly.

For example:
Reading the file "C:\a a\foo.class" would return zero bytes, because
clazz.getResource( classFileName ).getFile()
returns the String "/C:/a%20a/foo.class". So in the following
URL url = clazz.getResource( classFileName );
File file = new File( url.getFile() );
the file can not be found, because it searches for the "C:/a%20a"  
directory which doesn't exist.

Instead of url.getFile() use url.toURI()

Instead of clazz.getResourceAsStream( classFileName ) you can use  
url.openStream(), it throws IOException.

View raw message