|
From: <fhe...@is...> - 2005-06-24 20:13:32
|
Hi All,
When doing animation, I have saved my jpg file in the same directory as my
project.
When I run
URL image = URLResource.getResource("customer.jpg");
it doesn't work because the file name does not start with /.
If I type
URL image = URLResource.getResource("/customer.jpg");
it doesn't work because in the method
URLResource.getResource(String name)
a file object named \\customer.jpg is created, which does not exist.
If I change the code in URLResource.getResource(String name) so it first
check whether it starts with / to check in the Resources and the else
statement I move it up three lines, it works (see code at end of mail)
Is there a file naming convention (that uses DSOL) that I should know or
is a bugg in the code?
Francisco
public static URL getResource(final String name){
try{
if (name.startsWith("/")){
URL url = URLResource.class.getResource(name);
if (url != null){
return url;
}
url =
Thread.currentThread().getContextClassLoader().getResource(name.substring(1));
if (url != null){
return url;
}
}
else{
File file = new File(name);
if (file.exists()){
return new URL("file:" + name);
}
etc., etc.
|