List of usage examples for java.io IOException printStackTrace
public void printStackTrace()
From source file:org.brnvrn.Main.java
public static void main(String[] args) { Document doc = null; // the HTML tool page Document docObsolete = null;/*from ww w . j ava 2 s. c om*/ try { //Document doc = Jsoup.connect("http://taskwarrior.org/tools/").get(); ClassLoader classloader = Thread.currentThread().getContextClassLoader(); InputStream input = classloader.getResourceAsStream("Taskwarrior-Tools.html"); doc = Jsoup.parse(input, "UTF-8", "http://taskwarrior.org/"); input = classloader.getResourceAsStream("Taskwarrior-Tools-Obsolete.html"); docObsolete = Jsoup.parse(input, "UTF-8", "http://taskwarrior.org/"); } catch (IOException e) { e.printStackTrace(); } List<Tool> tools = new ArrayList<Tool>(100); ObjectMapper objectMapper = parseDocument(tools, doc, false); objectMapper = parseDocument(tools, docObsolete, true); try { objectMapper.writeValue(new FileOutputStream("data-tools.json"), tools); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.liuxuan.Tools.signup.SignupQjvpn.java
public static void main(String[] args) { try {//from w w w.ja v a2 s . c o m SignupQjvpn sign = new SignupQjvpn(); sign.getLoginForm(); sign.doLoginAction(); System.out.println("------------check---------------"); sign.check(); } catch (IOException ex) { ex.printStackTrace(); // Logger.getLogger(SignupV2ex.class.getName()).log(Level.SEVERE, null, ex); } catch (URISyntaxException ex) { ex.printStackTrace(); ; // Logger.getLogger(SignupV2ex.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:niclients.main.pubni.java
public static void main(String[] args) throws UnsupportedEncodingException { HttpClient client = new DefaultHttpClient(); if (commandparser(args)) { niname = addauthorityToNiname(niname, authority); }// w w w . ja va 2 s . c o m niname = niUtils.makenif(niname, filename); if (niname != null) { if (createpub()) { try { HttpResponse response = client.execute(post); int resp_code = response.getStatusLine().getStatusCode(); System.err.println("RESP_CODE: " + Integer.toString(resp_code)); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); String line = ""; while ((line = rd.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } } else { System.out.println("Niname creation failed!\n"); } } else { System.out.println("Command line parsing failed!\n"); } }
From source file:com.kotcrab.vis.editor.Main.java
public static void main(String[] args) throws Exception { App.init();// w w w . j a v a 2 s . c o m if (OsUtils.isMac()) System.setProperty("java.awt.headless", "true"); LaunchConfiguration launchConfig = new LaunchConfiguration(); //TODO: needs some better parser for (int i = 0; i < args.length; i++) { String arg = args[i]; if (arg.equals("--scale-ui")) { launchConfig.scaleUIEnabled = true; continue; } if (arg.equals("--project")) { if (i + 1 >= args.length) { throw new IllegalStateException("Not enough parameters for --project <project path>"); } launchConfig.projectPath = args[i + 1]; i++; continue; } if (arg.equals("--scene")) { if (i + 1 >= args.length) { throw new IllegalStateException("Not enough parameters for --scene <scene path>"); } launchConfig.scenePath = args[i + 1]; i++; continue; } Log.warn("Unrecognized command line argument: " + arg); } launchConfig.verify(); editor = new Editor(launchConfig); Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.setWindowedMode(1280, 720); config.setWindowSizeLimits(1, 1, 9999, 9999); config.useVsync(true); config.setIdleFPS(2); config.setWindowListener(new Lwjgl3WindowAdapter() { @Override public boolean closeRequested() { editor.requestExit(); return false; } }); try { new Lwjgl3Application(editor, config); Log.dispose(); } catch (Exception e) { Log.exception(e); Log.fatal("Uncaught exception occurred, error report will be saved"); Log.flush(); if (App.eventBus != null) App.eventBus.post(new ExceptionEvent(e, true)); try { File crashReport = new CrashReporter(Log.getLogFile().file()).processReport(); if (new File(App.TOOL_CRASH_REPORTER_PATH).exists() == false) { Log.warn("Crash reporting tool not present, skipping crash report sending."); } else { CommandLine cmdLine = new CommandLine(PlatformUtils.getJavaBinPath()); cmdLine.addArgument("-jar"); cmdLine.addArgument(App.TOOL_CRASH_REPORTER_PATH); cmdLine.addArgument(ApplicationUtils.getRestartCommand().replace("\"", "%")); cmdLine.addArgument(crashReport.getAbsolutePath(), false); DefaultExecutor executor = new DefaultExecutor(); executor.setStreamHandler(new PumpStreamHandler(null, null, null)); executor.execute(cmdLine); } } catch (IOException ex) { ex.printStackTrace(); } Log.dispose(); System.exit(-3); } catch (ExceptionInInitializerError err) { if (OsUtils.isMac() && err.getCause() instanceof IllegalStateException) { if (ExceptionUtils.getStackTrace(err).contains("XstartOnFirstThread")) { System.out.println( "Application was not launched on first thread. Restarting with -XstartOnFirstThread, add VM argument -XstartOnFirstThread to avoid this."); ApplicationUtils.startNewInstance(); } } throw err; } }
From source file:org.jetbrains.webdemo.executors.JunitExecutor.java
public static void main(String[] args) { try {/*from w w w . j av a 2 s. com*/ JUnitCore jUnitCore = new JUnitCore(); jUnitCore.addListener(new MyRunListener()); List<Class> classes = getAllClassesFromTheDir(new File(args[0])); for (Class cl : classes) { boolean hasTestMethods = false; for (Method method : cl.getMethods()) { if (method.isAnnotationPresent(Test.class)) { hasTestMethods = true; break; } } if (!hasTestMethods) continue; Request request = Request.aClass(cl); jUnitCore.run(request); } try { ObjectMapper objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addSerializer(Throwable.class, new ThrowableSerializer()); module.addSerializer(junit.framework.ComparisonFailure.class, new JunitFrameworkComparisonFailureSerializer()); module.addSerializer(org.junit.ComparisonFailure.class, new OrgJunitComparisonFailureSerializer()); objectMapper.registerModule(module); System.setOut(standardOutput); Map<String, List<TestRunInfo>> groupedTestResults = new HashMap<>(); for (TestRunInfo testRunInfo : output) { if (!groupedTestResults.containsKey(testRunInfo.className)) { groupedTestResults.put(testRunInfo.className, new ArrayList<TestRunInfo>()); } groupedTestResults.get(testRunInfo.className).add(testRunInfo); } System.out.print(objectMapper.writeValueAsString(groupedTestResults)); } catch (IOException e) { e.printStackTrace(); } } catch (Throwable e) { System.setOut(standardOutput); System.out.print("[\""); e.printStackTrace(); System.out.print("\"]"); } }
From source file:examples.messages.java
public static final void main(String[] args) { int message;//from w w w . j a v a2 s .c o m String server, username, password; POP3Client pop3; Reader reader; POP3MessageInfo[] messages; if (args.length < 3) { System.err.println("Usage: messages <pop3 server hostname> <username> <password>"); System.exit(1); } server = args[0]; username = args[1]; password = args[2]; pop3 = new POP3Client(); // We want to timeout if a response takes longer than 60 seconds pop3.setDefaultTimeout(60000); try { pop3.connect(server); } catch (IOException e) { System.err.println("Could not connect to server."); e.printStackTrace(); System.exit(1); } try { if (!pop3.login(username, password)) { System.err.println("Could not login to server. Check password."); pop3.disconnect(); System.exit(1); } messages = pop3.listMessages(); if (messages == null) { System.err.println("Could not retrieve message list."); pop3.disconnect(); System.exit(1); } else if (messages.length == 0) { System.out.println("No messages"); pop3.logout(); pop3.disconnect(); System.exit(1); } for (message = 0; message < messages.length; message++) { reader = pop3.retrieveMessageTop(messages[message].number, 0); if (reader == null) { System.err.println("Could not retrieve message header."); pop3.disconnect(); System.exit(1); } printMessageInfo(new BufferedReader(reader), messages[message].number); } pop3.logout(); pop3.disconnect(); } catch (IOException e) { e.printStackTrace(); System.exit(1); } }
From source file:Manager.java
public static void main(String[] args) throws SQLException { Manager manager = new Manager(); try {//from w w w .ja v a 2 s. c om //manager.loadMovieFiles(); try { manager.uploadFiles(); } catch (IOException e) { e.printStackTrace(); } catch (MahasenClientException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } catch (SQLException e) { e.printStackTrace(); } finally { manager.closeConnection(); } }
From source file:com.google.flightmap.parsing.faa.nfd.tools.RecordStructGenerator.java
public static void main(String args[]) { CommandLine line = null;//from w w w .j av a 2 s.com try { final CommandLineParser parser = new PosixParser(); line = parser.parse(OPTIONS, args); } catch (ParseException pEx) { System.err.println(pEx.getMessage()); printHelp(line); System.exit(1); } if (line.hasOption(HELP_OPTION)) { printHelp(line); System.exit(0); } final String defPath = line.getOptionValue(DEF_FILE_OPTION); final File def = new File(defPath); try { (new RecordStructGenerator(def)).execute(); } catch (IOException ioEx) { ioEx.printStackTrace(); System.exit(2); } }
From source file:com.atlauncher.Bootstrap.java
public static void main(String[] args) { String json = null;/*from w w w. ja v a2s . c om*/ if (!Files.isDirectory(PATH)) { try { Files.createDirectories(PATH); } catch (IOException e) { e.printStackTrace(); } } try { json = IOUtils.toString(URI.create("http://download.nodecdn.net/containers/atl/v4/app.json")); } catch (IOException e) { e.printStackTrace(); System.exit(1); } Application application = GSON.fromJson(json, Application.class); Dependency currentDependency = null; if (Files.exists(PATH.resolve("nwjs.json"))) { try { currentDependency = GSON.fromJson(FileUtils.readFileToString(PATH.resolve("nwjs.json").toFile()), Dependency.class); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } for (Dependency dependency : application.getDependencies()) { if (dependency.shouldInstall() && !dependency.matches(currentDependency)) { if (Files.isDirectory(PATH.resolve("nwjs/"))) { try { FileUtils.deleteDirectory(PATH.resolve("nwjs/").toFile()); } catch (IOException e) { e.printStackTrace(); } } try { File zipFile = PATH.resolve("nwjs/temp.zip").toFile(); FileUtils.copyURLToFile(dependency.getUrl(), zipFile); Utils.unzip(zipFile, PATH.resolve("nwjs/").toFile()); FileUtils.forceDelete(zipFile); currentDependency = dependency; FileUtils.writeStringToFile(PATH.resolve("nwjs.json").toFile(), GSON.toJson(dependency)); break; } catch (IOException e) { e.printStackTrace(); System.exit(1); } } } App currentApp = null; if (Files.exists(PATH.resolve("app.json"))) { try { currentApp = GSON.fromJson(FileUtils.readFileToString(PATH.resolve("app.json").toFile()), App.class); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } if (!application.getApp().matches(currentApp) || (currentApp != null && !Files.exists(PATH.resolve(currentApp.getFilename())))) { if (currentApp != null && Files.exists(PATH.resolve(currentApp.getFilename()))) { try { FileUtils.forceDelete(PATH.resolve(currentApp.getFilename()).toFile()); } catch (IOException e) { e.printStackTrace(); } } try { FileUtils.copyURLToFile(application.getApp().getUrl(), PATH.resolve(application.getApp().getFilename()).toFile()); currentApp = application.getApp(); FileUtils.writeStringToFile(PATH.resolve("app.json").toFile(), GSON.toJson(application.getApp())); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } if (currentDependency == null || currentApp == null) { System.exit(1); } List<String> arguments = new ArrayList<>(); arguments.add(PATH.resolve("nwjs/").toAbsolutePath() + currentDependency.getStartup()); arguments.add(currentApp.getFilename()); ProcessBuilder processBuilder = new ProcessBuilder(arguments); processBuilder.directory(PATH.toFile()); try { processBuilder.start(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.yahoo.labs.samoa.topology.impl.StormTopologySubmitter.java
public static void main(String[] args) throws IOException { Properties props = StormSamoaUtils.getProperties(); String uploadedJarLocation = props.getProperty(StormJarSubmitter.UPLOADED_JAR_LOCATION_KEY); if (uploadedJarLocation == null) { logger.error("Invalid properties file. It must have key {}", StormJarSubmitter.UPLOADED_JAR_LOCATION_KEY); return;//www . j a v a2 s.c o m } List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args)); int numWorkers = StormSamoaUtils.numWorkers(tmpArgs); args = tmpArgs.toArray(new String[0]); StormTopology stormTopo = StormSamoaUtils.argsToTopology(args); Config conf = new Config(); conf.putAll(Utils.readStormConfig()); conf.putAll(Utils.readCommandLineOpts()); conf.setDebug(false); conf.setNumWorkers(numWorkers); String profilerOption = props.getProperty(StormTopologySubmitter.YJP_OPTIONS_KEY); if (profilerOption != null) { String topoWorkerChildOpts = (String) conf.get(Config.TOPOLOGY_WORKER_CHILDOPTS); StringBuilder optionBuilder = new StringBuilder(); if (topoWorkerChildOpts != null) { optionBuilder.append(topoWorkerChildOpts); optionBuilder.append(' '); } optionBuilder.append(profilerOption); conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, optionBuilder.toString()); } Map<String, Object> myConfigMap = new HashMap<String, Object>(conf); StringWriter out = new StringWriter(); try { JSONValue.writeJSONString(myConfigMap, out); } catch (IOException e) { System.out.println("Error in writing JSONString"); e.printStackTrace(); return; } Config config = new Config(); config.putAll(Utils.readStormConfig()); String nimbusHost = (String) config.get(Config.NIMBUS_HOST); NimbusClient nc = new NimbusClient(nimbusHost); String topologyName = stormTopo.getTopologyName(); try { System.out.println("Submitting topology with name: " + topologyName); nc.getClient().submitTopology(topologyName, uploadedJarLocation, out.toString(), stormTopo.getStormBuilder().createTopology()); System.out.println(topologyName + " is successfully submitted"); } catch (AlreadyAliveException aae) { System.out.println("Fail to submit " + topologyName + "\nError message: " + aae.get_msg()); } catch (InvalidTopologyException ite) { System.out.println("Invalid topology for " + topologyName); ite.printStackTrace(); } catch (TException te) { System.out.println("Texception for " + topologyName); te.printStackTrace(); } }