List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:org.newdawn.ardor3d.loader.max.MaxModelViewer.java
/** * @param args// ww w . j av a 2 s .c o m */ public static void main(String[] args) { try { new MaxModelViewer().start(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.hdfstoftp.main.HdfsToFtp.java
/** * ?/*from ww w . java2 s . co m*/ * * @param args * @throws IOException * @throws ParseException */ public static void main(String[] args) throws IOException, ParseException { args = new String[] { "D:/input", "/home/heaven/whd", "-c d:/conf/hdfs-to-ftp.properties", "-t 20150820000000", "-r .*bak.*", "-o false" }; // args = new String[] { "d:/failed", "/home/heaven/whd" }; try { logger.info("your input param is=" + Arrays.toString(args)); Config config = new Config(args); logger.info("your config is =" + config.toString()); copyFromHDFSToFTP(config); } catch (URISyntaxException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.uniko.west.winter.test.basics.JenaTests.java
public static void main(String[] args) { Model newModel = ModelFactory.createDefaultModel(); // /* w ww .j a va2 s . c o m*/ Model newModel2 = ModelFactory.createModelForGraph(ModelFactory.createMemModelMaker().getGraphMaker() .createGraph("http://www.defaultgraph.de/graph1")); StringBuilder updateString = new StringBuilder(); updateString.append("PREFIX dc: <http://purl.org/dc/elements/1.1/>"); updateString.append("PREFIX xsd: <http://bla.org/dc/elements/1.1/>"); updateString.append("INSERT { "); updateString.append( "<http://example/egbook1> dc:title <http://example/egbook1/#Title1>, <http://example/egbook1/#Title2>. "); //updateString.append("<http://example/egbook1> dc:title \"Title1.1\". "); //updateString.append("<http://example/egbook1> dc:title \"Title1.2\". "); updateString.append("<http://example/egbook21> dc:title \"Title2\"; "); updateString.append("dc:title \"2.0\"^^xsd:double. "); updateString.append("<http://example/egbook3> dc:title \"Title3\". "); updateString.append("<http://example/egbook4> dc:title \"Title4\". "); updateString.append("<http://example/egbook5> dc:title \"Title5\". "); updateString.append("<http://example/egbook6> dc:title \"Title6\" "); updateString.append("}"); UpdateRequest update = UpdateFactory.create(updateString.toString()); UpdateAction.execute(update, newModel); StmtIterator iter = newModel.listStatements(); System.out.println("After add"); while (iter.hasNext()) { System.out.println(iter.next().toString()); } StringBuilder constructQueryString = new StringBuilder(); constructQueryString.append("PREFIX dc: <http://purl.org/dc/elements/1.1/>"); constructQueryString.append("CONSTRUCT {?sub dc:title <http://example/egbook1/#Title1>}"); constructQueryString.append("WHERE {"); constructQueryString.append("?sub dc:title <http://example/egbook1/#Title1>"); constructQueryString.append("}"); StringBuilder askQueryString = new StringBuilder(); askQueryString.append("PREFIX dc: <http://purl.org/dc/elements/1.1/>"); askQueryString.append("ASK {"); askQueryString.append("?sub dc:title <http://example/egbook1/#Title1>"); askQueryString.append("}"); StringBuilder selectQueryString = new StringBuilder(); selectQueryString.append("PREFIX dc: <http://purl.org/dc/elements/1.1/>"); selectQueryString.append("SELECT * "); selectQueryString.append("WHERE {"); selectQueryString.append("?sub ?pred ?obj"); selectQueryString.append("}"); Query cquery = QueryFactory.create(constructQueryString.toString()); System.out.println(cquery.getQueryType()); Query aquery = QueryFactory.create(askQueryString.toString()); System.out.println(aquery.getQueryType()); Query query = QueryFactory.create(selectQueryString.toString()); System.out.println(query.getQueryType()); QueryExecution queryExecution = QueryExecutionFactory.create(query, newModel); ByteArrayOutputStream baos = new ByteArrayOutputStream(); URI test = null; try { test = new URI("http://bla.org/dc/elements/1.1/double"); } catch (URISyntaxException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println(test.getPath().toString().substring(test.getPath().lastIndexOf("/") + 1)); System.out.println("java.lang." + test.getPath().toString().substring(test.getPath().lastIndexOf("/") + 1).substring(0, 1) .toUpperCase() + test.getPath().toString().substring(test.getPath().lastIndexOf("/") + 1).substring(1)); String typ = "java.lang.Boolean"; String val = "true"; try { Object typedLiteral = Class.forName(typ, true, ClassLoader.getSystemClassLoader()) .getConstructor(String.class).newInstance(val); System.out.println("Type: " + typedLiteral.getClass().getName() + " Value: " + typedLiteral); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { System.out.println("Query..."); com.hp.hpl.jena.query.ResultSet results = queryExecution.execSelect(); System.out.println("RESULT:"); ResultSetFormatter.output(System.out, results, ResultSetFormat.syntaxJSON); // // // ResultSetFormatter.outputAsJSON(baos, results); // System.out.println(baos.toString()); // System.out.println("JsonTest: "); // JSONObject result = new JSONObject(baos.toString("ISO-8859-1")); // for (Iterator key = result.keys(); result.keys().hasNext(); ){ // System.out.println(key.next()); // // for (Iterator key2 = ((JSONObject)result.getJSONObject("head")).keys(); key2.hasNext(); ){ // System.out.println(key2.next()); // } // } // Model results = queryExecution.execConstruct(); // results.write(System.out, "TURTLE"); // for ( ; results.hasNext() ; ){ // QuerySolution soln = results.nextSolution() ; // RDFNode x = soln.get("sub") ; // System.out.println("result: "+soln.get("sub")+" hasTitle "+soln.get("obj")); // Resource r = soln.getResource("VarR") ; // Literal l = soln.getLiteral("VarL") ; // // } } catch (Exception e) { // TODO: handle exception } // StringBuilder updateString2 = new StringBuilder(); // updateString2.append("PREFIX dc: <http://purl.org/dc/elements/1.1/>"); // updateString2.append("DELETE DATA { "); // updateString2.append("<http://example/egbook3> dc:title \"Title3\" "); // updateString2.append("}"); // // UpdateAction.parseExecute(updateString2.toString(), newModel); // // iter = newModel.listStatements(); // System.out.println("After delete"); // while (iter.hasNext()) { // System.out.println(iter.next().toString()); // // } // // StringBuilder updateString3 = new StringBuilder(); // updateString3.append("PREFIX dc: <http://purl.org/dc/elements/1.1/>"); // updateString3.append("DELETE DATA { "); // updateString3.append("<http://example/egbook6> dc:title \"Title6\" "); // updateString3.append("}"); // updateString3.append("INSERT { "); // updateString3.append("<http://example/egbook6> dc:title \"New Title6\" "); // updateString3.append("}"); // // UpdateAction.parseExecute(updateString3.toString(), newModel); // UpdateAction.parseExecute( "prefix exp: <http://www.example.de>"+ // "prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+ // "INSERT { graph <http://www.defaultgraph.de/graph1> {"+ // " <http://www.test.de#substructure1> <exp:has_relation3> <http://www.test.de#substructure2> ."+ // " <http://www.test.de#substructure1> <rdf:type> <http://www.test.de#substructuretype1> ."+ // " <http://www.test.de#substructure2> <rdf:type> <http://www.test.de#substructuretype2> ."+ // "}}", newModel2); // // iter = newModel.listStatements(); // System.out.println("After update"); // while (iter.hasNext()) { // System.out.println(iter.next().toString()); // // } }
From source file:com.cloud.storage.template.HttpTemplateDownloader.java
public static void main(String[] args) { String url = "http:// dev.mysql.com/get/Downloads/MySQL-5.0/mysql-noinstall-5.0.77-win32.zip/from/http://mirror.services.wisc.edu/mysql/"; try {// w w w.j av a 2s. c om URI uri = new java.net.URI(url); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } TemplateDownloader td = new HttpTemplateDownloader(null, url, "/tmp/mysql", null, TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES, null, null, null, null); long bytes = td.download(true, null); if (bytes > 0) { System.out .println("Downloaded (" + bytes + " bytes)" + " in " + td.getDownloadTime() / 1000 + " secs"); } else { System.out.println("Failed download"); } }
From source file:org.kepler.Kepler.java
public static void main(String[] args) { //System.out.println("java.library.path = " + System.getProperty("java.library.path")); // log4j uses the first log4j.properties file found on the classpath. // since kepler's classpath is complicated, it is not always obvious // which log4j.properties is used; it may be hidden in a jar file. // this prints the log4j.properties file found on the classpath. File log4jFile = FileUtilities.nameToFile("$CLASSPATH/log4j.properties", null); if (log4jFile == null) { System.out.println("log4j.properties not found in CLASSPATH."); } else {//from w ww .j a v a 2 s . c om System.out.println("log4j.properties found in CLASSPATH: " + log4jFile); } // Save the args in case they are needed later. // long startTime = System.currentTimeMillis(); _args = args; CommandLineArgs.store(args); List<String> argList = Arrays.asList(args); // parse the command line arguments if (!parseArgs(args)) { // an error occurred, so exit. return; } RepositoryLocations.setReleaseLocation(org.kepler.modulemanager.RepositoryLocations.getReleaseLocation()); ModuleTree.init(); // if we are executing a workflow from the command line, check now for // patches. if (_action == Action.RunKAR || _action == Action.RunWf) { // if we are running headless, do not display a dialog if patches // are available if (!_runWithGui || _displayRedirectOutputPath != null) { PatchChecker.check(true); } else { PatchChecker.check(false); } // show the splash if the Kepler UI is starting } else if (_action == Action.Kepler && _showSplash) { _showSplash(); } System.gc(); ShutdownNotifier.addShutdownListener(new Shutdown()); try { setJavaPropertiesAndCopyModuleDirectories(); // System.out.println("os: " + System.getProperty("os.name")); String OSName = System.getProperty("os.name"); // Hashtable properties = getProject().getProperties(); ModuleTree moduleTree = ModuleTree.instance(); String classpath = System.getProperty("java.class.path"); String[] classpathItems = classpath.split(File.pathSeparator); for (Module module : moduleTree) { // XXX since Module dir variables can be wrong, utilizing classpath // to determine module location on disk. Use below line instead when // that's fixed. //File osextension = new File(module.getModuleInfoDir() + File.separator + "osextension.txt"); File osextension = null; String sought = File.separator + module.getName() + File.separator; for (String path : classpathItems) { // must check each match since parent path could possibly have a module name // in it (don't break on first): if (path.contains(sought)) { int lastIndex = path.lastIndexOf(sought); String p = path.substring(0, lastIndex); p = p.concat(sought + "module-info" + File.separator + "osextension.txt"); osextension = new File(p); if (osextension.exists()) { break; } } } if (osextension == null || !osextension.exists()) { continue; } System.out.println("Found OS Extension file: " + osextension.getAbsolutePath()); Hashtable<String, String> properties = readOSExtensionFile(osextension); Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { String extClass = keys.nextElement(); String os = properties.get(extClass); if (OSName.trim().equals(os.trim())) { // if we're in an OS that an extension // needs to be loaded for attempt to load // the OSExtension via reflection // and run the addOSExtension method Class<?> c = Class.forName(extClass); try { OSExtension extension = (OSExtension) c.newInstance(); extension.addOSExtensions(); System.out.println("loading OS extensions for OS " + os + " with class " + extClass); } catch (ClassCastException cce) { // System.out.println(extClass + // " is not an instance of OSExtension"); } } } } Project project = new Project(); File projDir = ProjectLocator.getProjectDir(); project.setBaseDir(projDir); setOntologyIndexFile(); if (!argList.contains("-runwf")) { // Allow developers to turn off MakeKars by creating // a file called "skipMakeKars" in the project root File skipMakeKars = new File(projDir, "skipMakeKars"); if (!skipMakeKars.exists()) { MakeKars kar = new MakeKars(); kar.setProject(project); kar.init(); kar.run(); } } PermissionManager.makeNativeLibsExecutable(); // CreateIntroFileTask createIntroFileTask = new // CreateIntroFileTask(); // createIntroFileTask.execute(); } catch (URISyntaxException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } runApplication(); // System.exit(0); // long endTime = System.currentTimeMillis(); // System.out.println( (endTime-startTime)/1000.0 ); }
From source file:com.netscape.cms.servlet.test.ConfigurationTest.java
public static void main(String args[]) throws Exception { String host = null;/*from w w w. j a v a 2 s .c om*/ String port = null; String cstype = null; String token_pwd = null; String db_dir = "./"; String protocol = "https"; String pin = null; String extCertFile = null; int testnum = 1; // parse command line arguments Options options = new Options(); options.addOption("t", true, "Subsystem type"); options.addOption("h", true, "Hostname of the CS subsystem"); options.addOption("p", true, "Port of the CS subsystem"); options.addOption("w", true, "Token password"); options.addOption("d", true, "Directory for tokendb"); options.addOption("s", true, "preop pin"); options.addOption("e", true, "File for externally signed signing cert"); options.addOption("x", true, "Test number"); try { CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("t")) { cstype = cmd.getOptionValue("t"); } else { System.err.println("Error: no subsystem type provided."); usage(options); } if (cmd.hasOption("h")) { host = cmd.getOptionValue("h"); } else { System.err.println("Error: no hostname provided."); usage(options); } if (cmd.hasOption("p")) { port = cmd.getOptionValue("p"); } else { System.err.println("Error: no port provided"); usage(options); } if (cmd.hasOption("w")) { token_pwd = cmd.getOptionValue("w"); } else { System.err.println("Error: no token password provided"); usage(options); } if (cmd.hasOption("d")) { db_dir = cmd.getOptionValue("d"); } if (cmd.hasOption("s")) { pin = cmd.getOptionValue("s"); } if (cmd.hasOption("e")) { extCertFile = cmd.getOptionValue("e"); } if (cmd.hasOption("x")) { testnum = Integer.parseInt(cmd.getOptionValue("x")); } } catch (ParseException e) { System.err.println("Error in parsing command line options: " + e.getMessage()); usage(options); } // Initialize token try { CryptoManager.initialize(db_dir); } catch (AlreadyInitializedException e) { // it is ok if it is already initialized } catch (Exception e) { System.out.println("INITIALIZATION ERROR: " + e.toString()); System.exit(1); } // log into token CryptoManager manager = null; CryptoToken token = null; try { manager = CryptoManager.getInstance(); token = manager.getInternalKeyStorageToken(); Password password = new Password(token_pwd.toCharArray()); try { token.login(password); } catch (Exception e) { System.out.println("login Exception: " + e.toString()); if (!token.isLoggedIn()) { token.initPassword(password, password); } } } catch (Exception e) { System.out.println("Exception in logging into token:" + e.toString()); } SystemConfigClient client = null; try { ClientConfig config = new ClientConfig(); config.setServerURL(protocol + "://" + host + ":" + port); client = new SystemConfigClient(new PKIClient(config, null), cstype); } catch (URISyntaxException e1) { e1.printStackTrace(); System.exit(1); } ConfigurationRequest data = null; switch (testnum) { case 1: data = constructCAData(host, port, pin, db_dir, token_pwd, token); break; case 2: data = constructCloneCAData(host, port, pin, db_dir, token_pwd, token); break; case 3: data = constructKRAData(host, port, pin, db_dir, token_pwd, token); break; case 4: data = constructOCSPData(host, port, pin, db_dir, token_pwd, token); break; case 5: data = constructTKSData(host, port, pin, db_dir, token_pwd, token); break; case 6: data = constructSubCAData(host, port, pin, db_dir, token_pwd, token); break; case 7: data = constructExternalCADataPart1(host, port, pin, db_dir, token_pwd, token); break; case 8: data = constructExternalCADataPart2(host, port, pin, db_dir, token_pwd, token, extCertFile); break; default: System.out.println("Invalid test"); System.exit(1); } ConfigurationResponse response = client.configure(data); System.out.println("adminCert: " + response.getAdminCert().getCert()); List<SystemCertData> certs = response.getSystemCerts(); Iterator<SystemCertData> iterator = certs.iterator(); while (iterator.hasNext()) { SystemCertData cdata = iterator.next(); System.out.println("tag: " + cdata.getTag()); System.out.println("cert: " + cdata.getCert()); System.out.println("request: " + cdata.getRequest()); } }
From source file:md.mclama.com.ModManager.java
/** * Launch the application.// w w w.j a v a 2s . c o m */ public static void main(String[] args) { try { workDir = new File(ModManager.class.getProtectionDomain().getCodeSource().getLocation().toURI() .getPath().replace("McLauncher.jar", "")); System.out.println("Running McLauncher from " + workDir); } catch (URISyntaxException e1) { workDir = new File(""); e1.printStackTrace(); } // try { // // Get a file channel for the file // boolean FileNotLocked=false; // // // try { // FileWriter file2 = new FileWriter(System.getProperty("java.io.tmpdir") + "/McLauncher.lock"); // file2.write("McLauncher lock"); // file2.close(); // } catch (IOException e) { // FileNotLocked=true; // } // // File file = new File(System.getProperty("java.io.tmpdir") + "/McLauncher.lock"); // // FileChannel channel = new RandomAccessFile(file, "rw").getChannel(); // if(file.renameTo(file)) FileNotLocked=true; // if(FileNotLocked){ // JOptionPane.showMessageDialog(null, "Already running McLauncher, Only one instance allowed at a time\n" // + "Is this wrong? Delete McLauncher.lock in your temp folder"); // System.out.println("Already running McLauncher, Only one instance allowed at a time"); // System.exit(0); // } // lock = channel.lock(); // // try { // lock = channel.tryLock(); // } catch (OverlappingFileLockException e) { // } // channel.close(); // } catch (Exception e) { // } //Not added because i do not want to lock people out from using McLauncher if somehow this fails. // if(new File(System.getProperty("java.io.tmpdir") + "/McLauncher.lock").exists()){ // System.exit(0);//close this instance if McLauncher is already running. // } // try { // FileWriter file = new FileWriter(System.getProperty("java.io.tmpdir") + "/McLauncher.lock"); // file.write("McLauncher one instance lock"); // file.close(); // } catch (IOException e) { // System.out.println("Severe, failed to create temp lock file"); // } EventQueue.invokeLater(new Runnable() { public void run() { try { con = new Console(); con.setVisible(false); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - con.getWidth()) / 2); int y = (int) ((dimension.getHeight() - con.getHeight()) / 2); con.setLocation(x, y); } catch (Exception e) { e.printStackTrace(); } } }); EventQueue.invokeLater(new Runnable() { @Override public void run() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } ModManager frame = new ModManager(); frame.setResizable(false); frame.setVisible(true); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2); int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:Main.java
public static String getDomainName(String url) { String domain = ""; URI uri;/* w w w . j av a 2s. c om*/ try { uri = new URI(url); domain = uri.getHost(); } catch (URISyntaxException e) { e.printStackTrace(); } return domain.startsWith("www.") ? domain.substring(4) : domain; }
From source file:Main.java
public static HttpResponse getData(String url) { HttpResponse response = null;/*from w ww. j ava 2 s . c o m*/ try { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(); request.setURI(new URI(url)); response = client.execute(request); } catch (URISyntaxException e) { e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return response; }
From source file:org.gatherdata.commons.net.CbidFactory.java
public static URI createCbid(String algorithm, byte[] digest) { URI cbid = null;//from w w w .java 2s .c o m try { cbid = new URI("urn", NAMESPACE_NID + ":" + algorithm + ":" + new String(Hex.encodeHex(digest)), null); } catch (URISyntaxException e) { e.printStackTrace(); } return cbid; }