reading shapefile from jar

From: <chrisvanlith@b3partners.nl>
Date: Wed Jun 12 2002 - 15:17:18 EDT

Don and list,

I am not sure if I do something wrong or that BinaryFile class indeed has
a bug.

This is what I do.
In the properties I read the shapefile with line:
mytopo.shapeFile=data/shape/topo.jar!/topol01l.shp

This line gives errors with the standard BinaryFile class.
I changed the lines according to new 4.5 " url =
Thread.currentThread().getContextClassLoader().getResource(name);"
Still errors, because the exists function does not know how to handle the
! separator.

I added the following lines:

                int index = name.indexOf("!");
                if (index != -1) {
                    name = name.substring(name.indexOf(":") + 1, index);
                }
just before the "url =
Thread.currentThread().getContextClassLoader().getResource(name);" line in
the exists function.

Next the errors continue in the BinaryFile constructor, so I add
                int index = name.indexOf("!");
                String jarEntryName = null;
                if (index != -1) {
                    // skip !/ "
                    jarEntryName = name.substring(index + 2);
                    name = name.substring(name.indexOf(":") + 1, index);
                }
again before the "url =
Thread.currentThread().getContextClassLoader().getResource(name);" line.
Finally I add the jarEntryName back to the newname, just before the
setJarInputReader(newname) function is called.
                    if (jarEntryName!=null && !jarEntryName.equals(""))
                        newname += "!" + jarEntryName;

Now the whole thing seems to work, I am still testing. Maybe elsewhere
problems arise.

Is all this new, or am I taking the more complicated route.

Thanks in advance for your comments

Chris van Lith

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Wed Jun 12 15:19:42 2002

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT