List of usage examples for java.net MalformedURLException getStackTrace
public StackTraceElement[] getStackTrace()
From source file:com.ln.methods.Getcalendar.java
public static void Main() { //TODO store file locally and check if file changed == redownload try {//from w w w . j a v a 2 s. c om //Get source // System.setProperty("http.agent", "lnrev2"); URL calendar = new URL(Calendarurl); HttpURLConnection getsource = (HttpURLConnection) calendar.openConnection(); InputStream in = new BufferedInputStream(getsource.getInputStream()); //Write source Writer sw = new StringWriter(); char[] b = new char[1024]; Reader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); int n; while ((n = reader.read(b)) != -1) { sw.write(b, 0, n); } //Source == String && Send source for parsing Parser.source = sw.toString(); Betaparser.source = sw.toString(); //String lol = sw.toString(); //lol = StringUtils.substringBetween(lol, "<month year=\"2012\" num=\"2\">", "</month>"); //Parser.parse(); Betaparser.parse(); } catch (MalformedURLException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE); } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getStackTrace(), "Error", JOptionPane.WARNING_MESSAGE); } }
From source file:org.camera.service.CAMERARESTService.java
@Override public void attributeChanged(Attribute at) throws IllegalActionException { StringBuilder contents = new StringBuilder(); String filePath = paramF.getExpression().trim(); if (at == paramF && !ServiceUtils.checkEmptyString(paramF.getExpression())) { log.debug("G File path: " + gFilePath + " : " + "FilePath: " + filePath); try {//from w ww .j a v a 2s . c o m BufferedReader input = null; if (filePath.startsWith("http")) { URL urlLocation = new URL(filePath); input = new BufferedReader(new InputStreamReader(urlLocation.openStream())); } String line = null; //not declared within while loop while ((line = input.readLine()) != null) { contents.append(line); contents.append(System.getProperty("line.separator")); } SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new StringReader(contents.toString())); Element elementURL = doc.getRootElement().getChild("resources"); String serviceURL = elementURL.getAttributeValue("base_uri"); Element elementRES = elementURL.getChild("resource"); String resourceName = elementRES.getAttributeValue("name"); ResName = resourceName; Element elementMethod = elementRES.getChild("method"); String methodName = elementMethod.getAttributeValue("name"); List<Element> elemParameters = elementMethod.getChild("request").getChildren("parameter"); // Element elemStr = doc // .getRootElement().getChild("allNames").getChild("entity").getChild("NAMESTR"); methodType.setExpression(methodName); serviceSiteURL.setExpression(serviceURL); double[] position = new double[2]; position[0] = 150.0; position[1] = 110.0; System.out.println("Elements in the List: " + elemParameters.size()); if (!filePath.equals(gFilePath)) { ResName = resourceName; String appender = getAppender(); this.setDisplayName(ResName + appender); fileList.clear(); if (!ServiceUtils.checkEmptyString(gFilePath) && !ServiceUtils.checkEmptyString(getOldDisplayName())) { remAttributes(getOldDisplayName() + "_"); } oPortList = this.inputPortList(); for (Element element : elemParameters) { String tmp = element.getChild("name").getTextTrim(); String type = element.getChild("type").getTextTrim(); String descript = element.getChild("descriptive_name").getTextTrim(); // System.out.println("TMP: " + tmp + ", i= " + i); boolean check = checkIfPortNameExists(tmp); if (!check) { configureActorPort(tmp, descript, type); } // System.out.println("A: " + tmp); if (type.equals("file")) { fileList.add(tmp); } if (!ServiceUtils.checkEmptyString(filePath)) { // if(!ServiceUtils.checkEmptyString(gFilePath) || (ServiceUtils.checkEmptyString(gFilePath) && (ServiceUtils.checkEmptyString(tmpParam.getExpression())))){ position[1] = position[1] + 15.0; System.out.println("B: " + descript); configureActorParameter(ResName, appender, descript, type, position); // configureActorParameter(ResName+"_"+descript, type, position); } } gFilePath = filePath; System.out.println("AFTER G File path: " + gFilePath + " : " + "FilePath: " + filePath); removeMyPorts(); // It removes the remaining ports from the old list, which are redundant. setOldDisplayName(ResName); } System.out.println("TOTAL NUMBER OF FILES: " + fileList.size()); for (String fl : fileList) { log.debug("File: " + fl); } System.out.println("Total number of elements in the Old p LISt: " + oPortList.size()); } catch (MalformedURLException mfue) { mfue.getStackTrace(); throw new IllegalActionException("MalformedURLEXception thrown"); } catch (IOException ex) { ex.printStackTrace(); throw new IllegalActionException("IOException thrown"); } catch (NameDuplicationException nde) { nde.printStackTrace(); throw new IllegalActionException("NameDuplicationException thrown"); } catch (Exception e) { e.printStackTrace(); throw new IllegalActionException("Exception thrown"); } } else if (ServiceUtils.checkEmptyString(paramF.getExpression())) { gFilePath = null; try { removePorts(); if (ResName != null) { remAttributes(getOldDisplayName() + "_"); } } catch (NameDuplicationException nde) { System.out.println("Name is duplicated in...."); nde.printStackTrace(); throw new IllegalActionException("NameDuplicationException thrown"); } } else { super.attributeChanged(at); } }
From source file:org.talend.dataprofiler.core.ui.editor.indicator.UDIMasterPage.java
/** * check whether the ClassName Exist In Jars. * //from w w w .j a va 2s . c o m * @return boolean */ private boolean isClassNameExistInJars() { if (classNameForSave != null && jarPathForSave != null && !classNameForSave.trim().equals(PluginConstant.EMPTY_STRING) && !jarPathForSave.trim().equals(PluginConstant.EMPTY_STRING)) { // MOD by zshen for bug 18724 2011.02.23 for (IFile file : UDIUtils.getContainJarFile(jarPathForSave)) { TalendURLClassLoader cl; try { // Note that the 2nd parameter (classloader) is needed to load class UserDefinitionIndicator from // org.talend.dataquality plugin. cl = new TalendURLClassLoader(new URL[] { file.getLocation().toFile().toURI().toURL() }, IndicatorDefinitionMaterPage.class.getClassLoader()); Class<?> theClass = cl.findClass(classNameForSave); if (theClass != null) { return true; } } catch (MalformedURLException e1) { log.error(e1.getStackTrace()); } catch (ClassNotFoundException e1) { log.error(e1.getStackTrace()); } } return false; } else { return false; } }