|
From: Peter H.M. J. <p.h...@tb...> - 2005-06-27 07:41:38
|
Hi Francisco,
The naming convention is just the Java relative naming convention. You
can use the following:
URLResource.getResource("file:/c/tmp/customer.jpg"); //absolute file
URLResource.getResource("http://www.a.b.com/images/customer.jpg");
//absolute url
Relative depends on classpath. Let's assume the model is in a jar called
model.jar
URLResource.getResource("/customer.jpg"); relative image in classpath.
Must be in root of classpath (in the model.jar)
URLResource.getResource("/images/customer.jpg"); relative image in
images directory in classpath. Must be in model.jar!/images/ of
classpath (in the model.jar)
Peter
ps let me know if it does not work
fhe...@is... wrote:
>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.
>
>
>
>
>
>
>-------------------------------------------------------
>SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
>from IBM. Find simple to follow Roadmaps, straightforward articles,
>informative Webcasts and more! Get everything you need to get up to
>speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
>_______________________________________________
>Dsol-java mailing list
>Dso...@li...
>https://lists.sourceforge.net/lists/listinfo/dsol-java
>
>
--
Department of Systems Engineering
TU Delft, Faculty of Technology, Policy and Management
Jaffalaan 5, 2628BX Delft, The Netherlands
Phone: +31 (0)15 2781136
Mobile: +31 (0)6 51148923
Secr: +31 (0)15 2788380
Fax: +31 (0)15 2783429
E-mail: p.h...@tb...
Webpage: http://www.peter-jacobs.com
|