private NADConGridShift loadGridShiftInternal(URL latGridURL, URL longGridURL) throws FactoryException { // decide if text or binary grid will be used String latGridName = URLs.urlToFile(latGridURL).getPath(); String longGridName = URLs.urlToFile(longGridURL).getPath(); try { if ((latGridName.endsWith(".las") && longGridName.endsWith(".los")) || (latGridName.endsWith(".LAS") && longGridName.endsWith(".LOS"))) { return loadBinaryGrid(latGridURL, longGridURL); } else if ((latGridName.endsWith(".laa") && longGridName.endsWith(".loa")) || (latGridName.endsWith(".LAA") && longGridName.endsWith(".LOA"))) { return loadTextGrid(latGridURL, longGridURL); } else { throw new FactoryException( Errors.format( ErrorKeys.UNSUPPORTED_FILE_TYPE_$2, latGridName.substring(latGridName.lastIndexOf('.') + 1), longGridName.substring(longGridName.lastIndexOf('.') + 1))); // Note: the +1 above hide the dot, but also make sure that the code is // valid even if the path do not contains '.' at all (-1 + 1 == 0). } } catch (IOException exception) { final Throwable cause = exception.getCause(); if (cause instanceof FactoryException) { throw (FactoryException) cause; } throw new FactoryException(exception.getLocalizedMessage(), exception); } }