List of usage examples for java.io IOException printStackTrace
public void printStackTrace()
From source file:org.apache.streams.facebook.example.FacebookFriendFeedElasticsearch.java
public static void main(String[] args) { LOGGER.info(StreamsConfigurator.config.toString()); Config facebook = StreamsConfigurator.config.getConfig("facebook"); Config elasticsearch = StreamsConfigurator.config.getConfig("elasticsearch"); FacebookUserstreamConfiguration facebookUserstreamConfiguration; try {// w w w .j a va2 s.c o m facebookUserstreamConfiguration = MAPPER.readValue( facebook.root().render(ConfigRenderOptions.concise()), FacebookUserstreamConfiguration.class); } catch (IOException e) { e.printStackTrace(); return; } FacebookFriendFeedProvider provider = new FacebookFriendFeedProvider(facebookUserstreamConfiguration, ObjectNode.class); FacebookTypeConverter converter = new FacebookTypeConverter(ObjectNode.class, Activity.class); ElasticsearchWriterConfiguration elasticsearchWriterConfiguration = ElasticsearchConfigurator .detectWriterConfiguration(elasticsearch); ElasticsearchPersistWriter writer = new ElasticsearchPersistWriter(elasticsearchWriterConfiguration); StreamBuilder builder = new LocalStreamBuilder(); builder.newPerpetualStream(FacebookFriendFeedProvider.STREAMS_ID, provider); builder.addStreamsProcessor("converter", converter, 2, FacebookFriendFeedProvider.STREAMS_ID); builder.addStreamsPersistWriter("console", writer, 1, "converter"); builder.start(); }
From source file:org.bimserver.javamodelchecker.WriteToJson.java
public static void main(String[] args) { try {/*from ww w . j a va 2 s.com*/ ObjectMapper objectMapper = new ObjectMapper(); ObjectNode rootNode = objectMapper.createObjectNode(); ArrayNode array = objectMapper.createArrayNode(); rootNode.set("modelcheckers", array); ObjectNode objectNode = objectMapper.createObjectNode(); array.add(objectNode); objectNode.put("name", "Check window widths"); objectNode.put("description", "Check window widths"); objectNode.put("modelCheckerPluginClassName", "org.bimserver.javamodelchecker.JavaModelCheckerPlugin"); objectNode.put("code", changeClassName( FileUtils.readFileToString( new File("src/org/bimserver/javamodelchecker/WindowWidthChecker.java")), "WindowWidthChecker")); objectNode = objectMapper.createObjectNode(); array.add(objectNode); objectNode.put("name", "Pass always"); objectNode.put("description", "Pass always"); objectNode.put("modelCheckerPluginClassName", "org.bimserver.javamodelchecker.JavaModelCheckerPlugin"); objectNode.put("code", changeClassName( FileUtils.readFileToString(new File("src/org/bimserver/javamodelchecker/PassAlways.java")), "PassAlways")); objectNode = objectMapper.createObjectNode(); array.add(objectNode); objectNode.put("name", "Fail always"); objectNode.put("description", "Fail always"); objectNode.put("modelCheckerPluginClassName", "org.bimserver.javamodelchecker.JavaModelCheckerPlugin"); objectNode.put("code", changeClassName( FileUtils.readFileToString(new File("src/org/bimserver/javamodelchecker/FailAlways.java")), "FailAlways")); objectMapper.writerWithDefaultPrettyPrinter().writeValue(new File("modelcheckers.json"), rootNode); } catch (IOException e) { e.printStackTrace(); } }
From source file:edu.upc.eetac.dsa.exercices.java.lang.exceptions.App.java
public static void main(String[] args) throws FileNotFoundException { String filename = null;//from w w w . j ava2 s. c o m String maxInteger = null; Options options = new Options(); Option optionFile = OptionBuilder.withArgName("file").hasArg().withDescription("file with integers") .withLongOpt("file").create("f"); options.addOption(optionFile); Option optionMax = OptionBuilder.withArgName("max").hasArg() .withDescription("maximum integer allowed in the file").withLongOpt("max").create("M"); options.addOption(optionFile); options.addOption(optionMax); options.addOption("h", "help", false, "prints this message"); CommandLineParser parser = new GnuParser(); CommandLine line = null; try { // parse the command line arguments line = parser.parse(options, args); if (line.hasOption("h")) { // No hace falta preguntar por el parmetro "help". Ambos son sinnimos new HelpFormatter().printHelp(App.class.getCanonicalName(), options); return; } filename = line.getOptionValue("f"); if (filename == null) { throw new org.apache.commons.cli.ParseException( "You must provide the path to the file with numbers."); } maxInteger = line.getOptionValue("M"); } catch (ParseException exp) { System.err.println(exp.getMessage()); new HelpFormatter().printHelp(App.class.getCanonicalName(), options); return; } try { int[] numbers = (maxInteger != null) ? FileNumberReader.readFile(filename, Integer.parseInt(maxInteger)) : FileNumberReader.readFile(filename); for (int i = 0; i < numbers.length; i++) { System.out.println("Integer read: " + numbers[i]); } } catch (IOException e) { e.printStackTrace(); } catch (BigNumberException e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField nameTextField = new JTextField(); frame.add(nameTextField, BorderLayout.NORTH); FileReader reader = null;/* w ww. ja v a 2 s . co m*/ try { reader = new FileReader("fileName.txt"); nameTextField.read(reader, "fileName.txt"); } catch (IOException exception) { System.err.println("Load oops"); exception.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException exception) { System.err.println("Error closing reader"); exception.printStackTrace(); } } } frame.setSize(250, 100); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField nameTextField = new JTextField(); frame.add(nameTextField, BorderLayout.NORTH); FileWriter writer = null;//from ww w. j a va 2 s .c o m try { writer = new FileWriter("filename.txt"); nameTextField.write(writer); } catch (IOException exception) { System.err.println("Save oops"); exception.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (IOException exception) { System.err.println("Error closing writer"); exception.printStackTrace(); } } } frame.setSize(250, 100); frame.setVisible(true); }
From source file:PersonExt.java
public static void main(String[] args) { PersonExt p1 = new PersonExt("John", "Male", 6.7); PersonExt p2 = new PersonExt("Wally", "Male", 5.7); PersonExt p3 = new PersonExt("Katrina", "Female", 5.4); File fileObject = new File("personext.ser"); try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileObject))) { oos.writeObject(p1);/*from w w w. j a v a 2s . c o m*/ oos.writeObject(p2); oos.writeObject(p3); System.out.println(p1); System.out.println(p2); System.out.println(p3); } catch (IOException e1) { e1.printStackTrace(); } fileObject = new File("personext.ser"); try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fileObject))) { p1 = (PersonExt) ois.readObject(); p2 = (PersonExt) ois.readObject(); p3 = (PersonExt) ois.readObject(); // Let's display the objects that are read System.out.println(p1); System.out.println(p2); System.out.println(p3); // Print the input path System.out.println("Objects were read from " + fileObject.getAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) { try {//from ww w. j a v a 2s . co m File tempFile = File.createTempFile("myfile", ".tmp"); FileOutputStream fout = new FileOutputStream(tempFile); PrintStream out = new PrintStream(fout); out.println("some text"); } catch (IOException ex) { System.out.println("There was a problem creating/writing to the temp file"); ex.printStackTrace(); } }
From source file:edu.cuhk.hccl.IDConverter.java
public static void main(String[] args) { if (args.length < 2) { printUsage();//from w w w . java 2 s . c o m } try { File inFile = new File(args[0]); File outFile = new File(args[1]); if (inFile.isDirectory()) { System.out.println("ID Converting begins..."); FileUtils.forceMkdir(outFile); for (File file : inFile.listFiles()) { if (!file.isHidden()) processFile(file, new File(outFile.getAbsolutePath() + "/" + FilenameUtils.removeExtension(file.getName()) + "-long.txt")); } } else if (inFile.isFile()) { System.out.println("ID Converting begins..."); processFile(inFile, outFile); } else { printUsage(); } System.out.println("ID Converting finished."); } catch (IOException e) { e.printStackTrace(); } }
From source file:foldersync.FolderSync.java
/** * @param args the command line arguments *//*from w ww. ja va 2 s .co m*/ public static void main(String[] args) { // TODO code application logic here //JSONParser parser = new JSONParser(); try { Options options = new Options(args[0]); List<HashMap> watchList = options.watchesList(); while (true) { for (HashMap watch : watchList) { // System.out.println(watch); Sync sync = new Sync((String) watch.get("sourceDir"), (String) watch.get("destDir"), (List) watch.get("watch"), (List) watch.get("dontwatch")); sync.syncFolders(); } Thread.sleep(100); } } catch (IOException e) { System.out.println(e.getMessage()); e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:cn.codepub.redis.directory.Main.java
public static void main(String[] args) throws IOException { try {/* w ww.j a v a 2s .com*/ testRedisDirectoryWithShardedJedisPool(); } catch (IOException e) { e.printStackTrace(); } }