Example usage for java.io IOException printStackTrace

List of usage examples for java.io IOException printStackTrace

Introduction

In this page you can find the example usage for java.io IOException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:parser.JsonWriter.java

/**
 * Retrieves knowledge base file and starts parsing as well as serialization.
 * /*from   ww  w. j  a va 2s.  c  om*/
 * @param args
 * @throws IOException Reading of Excel File fails
 */
public static void main(String[] args) throws IOException {
    String filePath = "KnowledgeBase.xlsx";
    XSSFWorkbook workbook = null;
    // Create Workbook instance holding reference to .xlsx file located at resources folder
    InputStream in = JsonWriter.class.getClassLoader().getResourceAsStream(filePath);
    try {
        workbook = new XSSFWorkbook(in);
    } catch (IOException e) {
        e.printStackTrace();
    }
    writeCloudDSFJson(workbook);
    writeCloudDSFPlusJson(workbook);
    System.out.println("Finished");
}

From source file:statUtil.TurnMovementPlot.java

public static void main(String[] args) {
    //        try {
    try {/*from  w w w  . j  a  v a2 s.  c o m*/
        TurnMovementPlot tmPlot = new TurnMovementPlot("TurnMovementPlot");
        tmPlot.pack();
        RefineryUtilities.centerFrameOnScreen(tmPlot);
        tmPlot.setVisible(true);
        //            Data data = CSVData.getCSVData(TRACKER_CSV_LOG, MF_CSV_LOG);
        //            StdDraw.setCanvasSize((int) Math.round((data.maxX - data.minX)), (int) Math.round(data.maxY - data.minY));
        //            StdDraw.setXscale(data.minX, data.maxX);
        //            StdDraw.setYscale(data.minY, data.maxY);
        //            StdDraw.setPenRadius(0.005);
        //            int i = 0;
        //            for (Double[] csvRow : data.csvData) {
        //                Double normalizedSpd = (csvRow[3] - data.minSpd) * (255.0 / (data.maxSpd - data.minSpd));
        //                if (normalizedSpd < 0.0) {
        //                    normalizedSpd = 0.0;
        //                }
        //                if (normalizedSpd > 255.0) {
        //                    normalizedSpd = 255.0;
        //                }
        //                StdDraw.setPenColor((int) Math.round(normalizedSpd), 0, 255 - (int) Math.round(normalizedSpd));
        //                StdDraw.point(csvRow[0], csvRow[1]);
        ////                StdDraw.point(1.0, 1.0);
        //                System.out.println(i);
        //                i++;
        //            }

    } catch (IOException ex) {
        ex.printStackTrace();
    }
    //        } catch (IOException ex) {
    //            Logger.getLogger(CameraMovementPlot.class.getName()).log(Level.SEVERE, null, ex);
    //        }
}

From source file:rx.apache.http.examples.ExampleObservableHttp.java

public static void main(String args[]) {
    CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();

    //        final RequestConfig requestConfig = RequestConfig.custom()
    //                .setSocketTimeout(3000)
    //                .setConnectTimeout(3000).build();
    //        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
    //                .setDefaultRequestConfig(requestConfig)
    //                .setMaxConnPerRoute(20)
    //                .setMaxConnTotal(50)
    //                .build();

    try {/*from  w  ww  .j  a v a  2  s .  c  o m*/
        httpclient.start();
        executeViaObservableHttpWithForEach(httpclient);
        executeStreamingViaObservableHttpWithForEach(httpclient);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            httpclient.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }

    CloseableHttpAsyncClient httpClient = HttpAsyncClients.createDefault();
    ObservableHttp.createGet("http://www.wikipedia.com", httpClient).toObservable();
    ObservableHttp.createRequest(HttpAsyncMethods.createGet("http://www.wikipedia.com"), httpClient)
            .toObservable();
}

From source file:examples.echo.java

public static final void main(String[] args) {

    if (args.length == 1) {
        try {//from w  w w.  java 2s.  c om
            echoTCP(args[0]);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    } else if (args.length == 2 && args[0].equals("-udp")) {
        try {
            echoUDP(args[1]);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    } else {
        System.err.println("Usage: echo [-udp] <hostname>");
        System.exit(1);
    }

}

From source file:com.ibm.watson.catalyst.corpus.tfidf.SearchTemplate.java

public static void main(String[] args) {

    System.out.println("Loading Corpus.");
    TermCorpusBuilder cb = new TermCorpusBuilder();
    cb.setDocumentCombiner(0, 0);/*  w  ww  .  jav a2  s  . c o m*/
    cb.setJson(new File("health-corpus.json"));
    TermCorpus c = cb.build();

    List<TermDocument> termDocuments = c.getDocuments();
    List<TemplateMatch> matches = new ArrayList<TemplateMatch>();

    Pattern p3 = Template.getTemplatePattern(new File("verbs-list.words"), "\\b(\\w+ )", "( \\w+)\\b");

    int index = 0;
    for (TermDocument termDocument : termDocuments) {
        DocumentMatcher dm = new DocumentMatcher(termDocument);

        matches.addAll(dm.getParagraphMatches(p3, "", ""));

        double progress = ((double) ++index / (double) termDocuments.size());
        System.out.print("Progress " + progress + "\r");
    }
    System.out.println();

    WordFrequencyHashtable f = new WordFrequencyHashtable();

    for (TemplateMatch match : matches) {
        f.put(match.getMatch(), 1);
    }

    JsonNode jn = f.toJsonNode(5);

    try (BufferedWriter bw = new BufferedWriter(new FileWriter("health-trigrams.json"))) {
        bw.write(jn.toString());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.xyz.reccommendation.driver.SKU2SKUCount.java

public static void main(String[] args) throws Exception {

    final Configuration conf = new Configuration();

    String envt = null;// w ww.  ja  va  2 s. c  o  m

    if (args.length > 0) {
        envt = args[0];
    } else {
        envt = "dev";
    }

    Properties prop = new Properties();

    try {
        // load a properties file from class path, inside static method
        prop.load(SKU2SKUCount.class.getClassLoader().getResourceAsStream("config-" + envt + ".properties"));

    } catch (IOException ex) {
        ex.printStackTrace();
        System.exit(1);
    }

    MongoConfigUtil.setOutputURI(conf, "mongodb://" + prop.getProperty("mongodb.ip") + "/"
            + prop.getProperty("mongodb.dbname") + ".out_stat_custom");

    log.debug("MongoDB URL : mongodb://" + prop.getProperty("mongodb.ip") + "/"
            + prop.getProperty("mongodb.dbname") + "." + ".out_stat_custom");

    log.debug("Conf: " + conf);

    MongoConfigUtil.setCreateInputSplits(conf, false);
    args = new GenericOptionsParser(conf, args).getRemainingArgs();

    final Job job = new Job(conf,
            "Count the sku to sku mapping from pview data on hdfs in \"inputPview\" path.");

    job.setJarByClass(SKU2SKUCount.class);

    job.setMapperClass(TokenizerMapper.class);

    // job.setCombinerClass(IntSumReducer.class);
    job.setReducerClass(IntSumReducer.class);

    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(IntWritable.class);

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(BSONWritable.class);

    job.setInputFormatClass(KeyValueTextInputFormat.class);
    job.setOutputFormatClass(MongoOutputFormat.class);

    FileInputFormat.setInputPaths(job, new Path("inputPview"));

    System.exit(job.waitForCompletion(true) ? 0 : 1);

}

From source file:com.puffywhiteshare.PWSApp.java

/**
 * @param args// w ww.  j av a 2 s  . c  om
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
    CloudBucket cloud = new CloudBucket();
    logger.info("Test my output bitches");
    Yaml y = new Yaml();
    File f = new File("Playing.yml");
    FileInputStream fis = new FileInputStream(f);
    Map m = (Map) y.load(fis);

    Long startFiles = System.currentTimeMillis();
    Iterator<File> fileIterator = FileUtils.iterateFiles(new File("/Users/chad/Pictures/."), null, true);
    do {
        File file = fileIterator.next();
        cloud.add(file);
    } while (fileIterator.hasNext());
    Long endFiles = System.currentTimeMillis();
    System.out.println("Files processing took " + ((endFiles - startFiles)));

    Long startSer = System.currentTimeMillis();
    String filename = "cloud.ser";
    FileOutputStream fos = null;
    ObjectOutputStream out = null;
    try {
        fos = new FileOutputStream(filename);
        out = new ObjectOutputStream(fos);
        out.writeObject(cloud);
        out.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    Long endSer = System.currentTimeMillis();
    System.out.println("Files processing took " + ((endSer - startSer)));

    logger.info(" Size = " + FileUtils.byteCountToDisplaySize(cloud.getSize()));
    logger.info("Count = " + cloud.getCount());

    /*
    Set<String> buckets = m.keySet();
    System.out.println(m.toString());
    for(String bucket : buckets) {
       logger.info("Bucket = " + bucket);
       logger.info("Folders = " + m.get(bucket));
       List<Object> folders = (List<Object>) m.get(bucket);
       for(Object folder : folders) {
    if(folder instanceof String) {
       logger.info("Folder Root = " + folder);
    } else if(folder instanceof Map) {
       logger.info("Folder Map = " + folder);
    }
       }
       BlockingQueue<File> fileFeed = new ArrayBlockingQueue<File>(10);
               
       Map folderMap = (Map) m.get(bucket);
       Set<String> folders = folderMap.entrySet();
       for(String folder : folders) {
    logger.info("Folder = " + folder);
       }
               
    }
    */
}

From source file:examples.unix.echo.java

public static void main(String[] args) {

    if (args.length == 1) {
        try {/*  w  w w. j  a va 2s .  co m*/
            echoTCP(args[0]);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    } else if (args.length == 2 && args[0].equals("-udp")) {
        try {
            echoUDP(args[1]);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    } else {
        System.err.println("Usage: echo [-udp] <hostname>");
        System.exit(1);
    }

}

From source file:uk.ac.kcl.Main.java

public static void main(String[] args) {
    File folder = new File(args[0]);
    File[] listOfFiles = folder.listFiles();
    assert listOfFiles != null;
    for (File listOfFile : listOfFiles) {
        if (listOfFile.isFile()) {
            if (listOfFile.getName().endsWith(".properties")) {
                System.out.println("Properties sile found:" + listOfFile.getName()
                        + ". Attempting to launch application context");
                Properties properties = new Properties();
                InputStream input;
                try {
                    input = new FileInputStream(listOfFile);
                    properties.load(input);
                    if (properties.getProperty("globalSocketTimeout") != null) {
                        TcpHelper.setSocketTimeout(
                                Integer.valueOf(properties.getProperty("globalSocketTimeout")));
                    }// w ww  . j  a  va  2s  .  com
                    Map<String, Object> map = new HashMap<>();
                    properties.forEach((k, v) -> {
                        map.put(k.toString(), v);
                    });
                    ConfigurableEnvironment environment = new StandardEnvironment();
                    MutablePropertySources propertySources = environment.getPropertySources();
                    propertySources.addFirst(new MapPropertySource(listOfFile.getName(), map));
                    @SuppressWarnings("resource")
                    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
                    ctx.registerShutdownHook();
                    ctx.setEnvironment(environment);
                    String scheduling;
                    try {
                        scheduling = properties.getProperty("scheduler.useScheduling");
                        if (scheduling.equalsIgnoreCase("true")) {
                            ctx.register(ScheduledJobLauncher.class);
                            ctx.refresh();
                        } else if (scheduling.equalsIgnoreCase("false")) {
                            ctx.register(SingleJobLauncher.class);
                            ctx.refresh();
                            SingleJobLauncher launcher = ctx.getBean(SingleJobLauncher.class);
                            launcher.launchJob();
                        } else if (scheduling.equalsIgnoreCase("slave")) {
                            ctx.register(JobConfiguration.class);
                            ctx.refresh();
                        } else {
                            throw new RuntimeException(
                                    "useScheduling not configured. Must be true, false or slave");
                        }
                    } catch (NullPointerException ex) {
                        throw new RuntimeException(
                                "useScheduling not configured. Must be true, false or slave");
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:ezbake.local.accumulo.LocalAccumulo.java

public static void main(String args[]) throws Exception {
    Logger logger = LoggerFactory.getLogger(LocalAccumulo.class);
    final File accumuloDirectory = Files.createTempDir();

    int shutdownPort = 4445;
    MiniAccumuloConfig config = new MiniAccumuloConfig(accumuloDirectory, "strongpassword");
    config.setZooKeeperPort(12181);/* ww w . ja v  a2  s . c  o  m*/

    final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(config);

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                accumulo.stop();
                FileUtils.deleteDirectory(accumuloDirectory);
                System.out.println("\nShut down gracefully on " + new Date());
            } catch (IOException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    });

    accumulo.start();

    printInfo(accumulo, shutdownPort);

    if (args.length > 0) {
        logger.info("Adding the following authorizations: {}", Arrays.toString(args));
        Authorizations auths = new Authorizations(args);
        Instance inst = new ZooKeeperInstance(accumulo.getConfig().getInstanceName(), accumulo.getZooKeepers());
        Connector client = inst.getConnector("root", new PasswordToken(accumulo.getConfig().getRootPassword()));
        logger.info("Connected...");
        client.securityOperations().changeUserAuthorizations("root", auths);
        logger.info("Auths updated");
    }

    // start a socket on the shutdown port and block- anything connected to this port will activate the shutdown
    ServerSocket shutdownServer = new ServerSocket(shutdownPort);
    shutdownServer.accept();

    System.exit(0);
}