private void loadJSHint() { jshint = new JSHint(); try { if (library != null) { FileInputStream inputStream = new FileInputStream(library); try { jshint.load(inputStream); } finally { inputStream.close(); } } else { jshint.load(); } } catch (Exception exception) { String message = "Failed to load JSHint library: " + exception.getMessage(); throw new IllegalArgumentException(message); } }
private static void validateFile(File file) throws IllegalArgumentException { if (!file.isFile()) { throw new IllegalArgumentException("File does not exist"); } if (!file.canRead()) { throw new IllegalArgumentException("File is not readable"); } try { FileInputStream inputStream = new FileInputStream(file); try { JSHint jsHint = new JSHint(); jsHint.load(inputStream); } finally { inputStream.close(); } } catch (Exception exception) { throw new IllegalArgumentException("File is not a valid JSHint library", exception); } }