The Shapefilereader from Vivisolutions works perfectly in Windows, but in multiple ubuntu instances I get this error:
java.lang.StringIndexOutOfBoundsException: String index out of range: 438 at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:906) at java.lang.StringBuffer.substring(StringBuffer.java:482) at org.geotools.dbffile.DbfFile.ParseRecordColumn(DbfFile.java:247) at com.vividsolutions.jump.io.ShapefileReader.read(ShapefileReader.java:175)
Code for reading the shapefile is:
public static FeatureCollection readShapefile(String shpFile)
{
File file = new File(shpFile);
if (!file.exists())
Application.logError("File does not exist " + file.getName());
ShapefileReader reader = new ShapefileReader();
FeatureCollection collection = null;
try {
collection = reader.read(new DriverProperties(shpFile));
} catch (IllegalParametersException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return collection;
}
I ensured that both the windows machine and the ubuntu machine have the same version of java installed.
In ubuntu, java -version gives
java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
In windows, java -version gives
java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Is there any reason they would be behaving different? Reading the error, the geotools dbffile parser runs into an issue. I've done a lot of searching and testing, the DBF file seems to be fine and can be read in multiple programs, including this one when run under windows.