/** * Checks to make sure the URL File exists. * * @param iFilePath is a String that represents the URL. * @return boolean that indicates is the file exists. */ private boolean fileExists(final String iFilePath) { boolean passed = true; try { // This is an external file if (URIHandler.isURL(iFilePath)) { final URL url = new URL(iFilePath); final URLConnection urlConn = url.openConnection(); final HttpURLConnection httpUrlConn = (HttpURLConnection) urlConn; final int code = httpUrlConn.getResponseCode(); // try to access the address if (code == HttpURLConnection.HTTP_OK) { mResult.addPackageCheckerMessage( new ValidatorMessage( ValidatorMessage.PASSED, Messages.getString("RequiredFilesChecker.11", iFilePath))); passed = true; } else { mResult.addPackageCheckerMessage( new ValidatorMessage( ValidatorMessage.FAILED, Messages.getString("RequiredFilesChecker.12", iFilePath))); passed = false; } } else { final URIHandler uriHandler = new URIHandler(); // Process file path String tempPath = iFilePath; tempPath = URIHandler.decode(tempPath, URIHandler.ENCODING); tempPath = uriHandler.escapeDirectories(tempPath); tempPath = tempPath.replaceAll("/", File.separator + File.separator); final File tempFile = new File(tempPath); passed = tempFile.exists(); } } catch (MalformedURLException mfue) { mResult.addPackageCheckerMessage( new ValidatorMessage( ValidatorMessage.FAILED, Messages.getString("RequiredFilesChecker.13", iFilePath))); passed = false; } catch (IOException ioe) { mResult.addPackageCheckerMessage( new ValidatorMessage( ValidatorMessage.FAILED, Messages.getString("RequiredFilesChecker.14", iFilePath))); passed = false; } return passed; }