Example usage for java.util.logging Level SEVERE

List of usage examples for java.util.logging Level SEVERE

Introduction

In this page you can find the example usage for java.util.logging Level SEVERE.

Prototype

Level SEVERE

To view the source code for java.util.logging Level SEVERE.

Click Source Link

Document

SEVERE is a message level indicating a serious failure.

Usage

From source file:hk.mcc.utils.applog2es.Main.java

/**
 * @param args the command line arguments
 *///  ww w .  j  ava 2s  . c om
public static void main(String[] args) throws Exception {
    String pathString = "G:\\tmp\\Archive20160902";
    Path path = Paths.get(pathString);
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(path, "app*.log")) {
        for (Path entry : stream) {
            List<AppLog> appLogs = new ArrayList<>();
            try (AppLogParser appLogParser = new AppLogParser(Files.newInputStream(entry))) {
                AppLog nextLog = appLogParser.nextLog();
                while (nextLog != null) {
                    //    System.out.println(nextLog);
                    nextLog = appLogParser.nextLog();
                    appLogs.add(nextLog);
                }

                post2ES(appLogs);
            } catch (IOException ex) {
                Logger.getLogger(AppLogParser.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

}

From source file:ie.peternagy.jcrypto.cli.JCryptoCli.java

public static void main(String[] args) {
    long startTime = System.currentTimeMillis();
    try {/*from  ww  w. ja va  2s. c o m*/
        CommandLineParser parser = new DefaultParser();
        CommandLine line = parser.parse(OPTIONS, args);
        isVerbose = line.hasOption('v');

        routeParams(line);

        if (isVerbose) {
            System.out.printf("\n Process finished in %dms\n\n", System.currentTimeMillis() - startTime);
        }
    } catch (org.apache.commons.cli.ParseException ex) {
        printCliHelp();
        //@todo: override the logger if not in debug mode
        Logger.getLogger(JCryptoCli.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:comparetopics.CompareTopics.java

/**
 * @param args the command line arguments
 *///from  w  w  w . j  a v  a2s. c  om
public static void main(String[] args) {
    try {
        File file1 = new File(
                "/Users/apple/Desktop/graduation-project/topic-modeling/output/jhotdraw-extracted-code/keys.txt");
        File file2 = new File(
                "/Users/apple/Desktop/graduation-project/topic-modeling/output/jhotdraw-extracted-code/keys.txt");

        CompareTopics compareTopics = new CompareTopics();
        String[] words1 = compareTopics.getWords(file1);
        String[] words2 = compareTopics.getWords(file2);
        StringBuffer words = new StringBuffer();

        File outputFile = new File("/Users/apple/Desktop/test.txt");
        if (outputFile.createNewFile()) {
            System.out.println("Create successful: " + outputFile.getName());
        }
        boolean hasSame = false;

        for (String w1 : words1) {
            if (!NumberUtils.isNumber(w1)) {
                for (String w2 : words2) {
                    if (w1.equals(w2)) {
                        words.append(w1);
                        //                            words.append("\r\n");
                        words.append(" ");
                        hasSame = true;
                        break;
                    }
                }
            }
        }
        if (!hasSame) {
            System.out.println("No same word.");
        } else {
            compareTopics.printToFile(words.toString(), outputFile);
        }

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

}

From source file:com.mycompany.myelasticsearch.MainClass.java

/**
 * @param args the command line arguments
 *///  ww w .j a v  a2  s .  co  m
public static void main(String[] args) {

    // TODO code application logic here
    Tika tika = new Tika();
    String fileEntry = "C:\\Contract\\Contract1.pdf";
    String filetype = tika.detect(fileEntry);
    System.out.println("FileType " + filetype);
    BodyContentHandler handler = new BodyContentHandler(-1);
    String text = "";
    Metadata metadata = new Metadata();

    FileInputStream inputstream = null;

    try {
        inputstream = new FileInputStream(fileEntry);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    }
    ParseContext pcontext = new ParseContext();

    //parsing the document using PDF parser
    PDFParser pdfparser = new PDFParser();
    try {
        pdfparser.parse(inputstream, handler, metadata, pcontext);
    } catch (IOException ex) {

        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SAXException ex) {
        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    } catch (TikaException ex) {
        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    }
    String docText = "";
    String outputArray[];
    String out[];
    //getting the content of the document
    docText = handler.toString().replaceAll("(/[^\\da-zA-Z.]/)", "");

    // PhraseDetection.getPhrases(docText);
    try {
        Node node = nodeBuilder().node();
        Client client = node.client();
        DocumentReader.parseString(docText, client);
        //"Borrowing should be replaced by the user input key"
        Elastic.getDefinedTerm(client, "definedterms", "term", "1", "Borrowing");
        node.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    }
    Stanford.getSentence(docText);

    int definedTermsEnd = docText.indexOf("SCHEDULES");
    String toc = docText.substring(0, definedTermsEnd);
    String c = docText.substring(definedTermsEnd);

    System.out.println("Table of content" + toc);
    System.out.println("--------------------------------");
    System.out.println("content" + c);

    out = toc.split("Article|article|ARTICLE");
    int count = 0;
    String outputArrayString = "";
    int s = 0;
    StringBuffer tocOutput = new StringBuffer();

    for (String o : out) {
        if (count != 0) {
            s = Integer.parseInt(String.valueOf(o.charAt(1)));
            if (s == count) {
                tocOutput.append(o);
                tocOutput.append("JigarAnkitNeeraj");
                System.out.println(s);
            }
        }
        outputArrayString += "Count" + count + o;
        count++;
        System.out.println();
    }
    System.out.println("---------------------------------------------------Content---------");
    count = 1;
    StringBuffer contentOutput = new StringBuffer();

    String splitContent[] = c.split("ARTICLE|Article");
    Node node = nodeBuilder().node();
    Client client = node.client();
    for (String o : splitContent) {
        o = o.replaceAll("[^a-zA-Z0-9.,\\/#!$%\\^&\\*;:{}=\\-_`~()?\\s]+", "");
        o = o.replaceAll("\n", " ");
        char input = o.charAt(1);
        if (input >= '0' && input <= '9') {
            s = Integer.parseInt(String.valueOf(o.charAt(1)));
            if (s == count) {
                //System.out.println(s);
                JSONObject articleJSONObject = new JSONObject();
                contentOutput.append(" \n MyArticlesSeparated \n ");
                articleJSONObject.put("Article" + count, o.toString());
                try {
                    try {
                        JSONObject articleJSONObject1 = new JSONObject();
                        articleJSONObject1.put("hi", "j");
                        client.prepareIndex("contract", "article", String.valueOf(count))
                                .setSource(articleJSONObject.toString()).execute().actionGet();
                    } catch (Exception e) {
                        System.out.println(e.getMessage());
                    }
                    //"Borrowing should be replaced by the user input key"

                } catch (Exception ex) {
                    Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println(s);
                count++;
            }
            //outputArrayString += "Count" + count + o;

            contentOutput.append(o);
        }
    }
    Elastic.getDocument(client, "contract", "article", "1");
    Elastic.searchDocument(client, "contract", "article", "Lenders");
    Elastic.searchDocument(client, "contract", "article", "Negative Covenants");

    Elastic.searchDocument(client, "contract", "article", "Change in Law");
    String tableOfContent[];
    tableOfContent = tocOutput.toString().split("JigarAnkitNeeraj");

    String splitContectsAccordingToArticles[];
    splitContectsAccordingToArticles = contentOutput.toString().split("MyArticlesSeparated");
    int numberOfArticle = splitContectsAccordingToArticles.length;

    int countArticle = 1;
    Double toBeTruncated = new Double("" + countArticle + ".00");

    String section = "Section";
    toBeTruncated += 0.01;

    System.out.println(toBeTruncated);
    String sectionEnd;
    StringBuffer sectionOutput = new StringBuffer();
    int skipFirstArtcile = 0;
    JSONObject obj = new JSONObject();

    for (String article : splitContectsAccordingToArticles) {
        if (skipFirstArtcile != 0) {
            DecimalFormat f = new DecimalFormat("##.00");
            String sectionStart = section + " " + f.format(toBeTruncated);
            int start = article.indexOf(sectionStart);
            toBeTruncated += 0.01;

            System.out.println();
            sectionEnd = section + " " + f.format(toBeTruncated);

            int end = article.indexOf(sectionEnd);
            while (end != -1) {
                sectionStart = section + " " + f.format(toBeTruncated - 0.01);
                sectionOutput.append(" \n Key:" + sectionStart);
                if (start < end) {
                    sectionOutput.append("\n Value:" + article.substring(start, end));
                    obj.put(sectionStart, article.substring(start, end).replaceAll("\\r\\n|\\r|\\n", " "));
                    try {
                        try {
                            JSONObject articleJSONObject1 = new JSONObject();
                            articleJSONObject1.put("hi", "j");
                            client.prepareIndex("contract", "section", String.valueOf(count))
                                    .setSource(obj.toString()).execute().actionGet();
                        } catch (Exception e) {
                            System.out.println(e.getMessage());
                        }
                        //"Borrowing should be replaced by the user input key"

                    } catch (Exception ex) {
                        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }

                start = end;
                toBeTruncated += 0.01;
                sectionEnd = section + " " + f.format(toBeTruncated);
                System.out.println("SectionEnd " + sectionEnd);
                try {
                    end = article.indexOf(sectionEnd);
                } catch (Exception e) {
                    System.out.print(e.getMessage());
                }

                System.out.println("End section index " + end);
            }
            end = article.length() - 1;
            sectionOutput.append(" \n Key:" + sectionStart);
            try {
                sectionOutput.append(" \n Value:" + article.substring(start, end));
                obj.put(sectionStart, article.substring(start, end).replaceAll("\\r\\n|\\r|\\n", " "));
            } catch (Exception e) {
                //What if Article has No Sections
                String numberOnly = article.replaceAll("[^0-9]", "").substring(0, 1);
                String sectionArticle = "ARTICLE " + numberOnly;
                sectionOutput.append(" \n Value:" + article);
                obj.put(sectionArticle, article);

                System.out.println(e.getMessage());
            }

            DecimalFormat ff = new DecimalFormat("##");
            toBeTruncated = Double.valueOf(ff.format(toBeTruncated)) + 1.01;
        }
        skipFirstArtcile++;
    }

    for (String article : splitContectsAccordingToArticles) {
        if (skipFirstArtcile != 0) {
            DecimalFormat f = new DecimalFormat("##.00");
            String sectionStart = section + " " + f.format(toBeTruncated);
            int start = article.indexOf(sectionStart);
            toBeTruncated += 0.01;
            System.out.println();
            sectionEnd = section + " " + f.format(toBeTruncated);

            int end = article.indexOf(sectionEnd);
            while (end != -1) {
                sectionStart = section + " " + f.format(toBeTruncated - 0.01);
                sectionOutput.append(" \n Key:" + sectionStart);
                if (start < end) {
                    sectionOutput.append("\n Value:" + article.substring(start, end));
                    System.out.println(sectionOutput);
                    String patternStr = "\\n\\n+[(]";
                    String paragraphSubstringArray[] = article.substring(start, end).split(patternStr);

                    JSONObject paragraphObject = new JSONObject();
                    int counter = 0;
                    for (String paragraphSubstring : paragraphSubstringArray) {
                        counter++;
                        paragraphObject.put("Paragraph " + counter, paragraphSubstring);

                    }
                    obj.put(sectionStart, paragraphObject);

                }

                start = end;
                toBeTruncated += 0.01;
                sectionEnd = section + " " + f.format(toBeTruncated);
                System.out.println("SectionEnd " + sectionEnd);
                try {
                    end = article.indexOf(sectionEnd);
                } catch (Exception e) {
                    System.out.print(e.getMessage());
                }

                System.out.println("End section index " + end);
            }
            end = article.length() - 1;
            sectionOutput.append(" \n Key:" + sectionStart);
            try {
                sectionOutput.append(" \n Value:" + article.substring(start, end));
                obj.put(sectionStart, article.substring(start, end));
                PhraseDetection.getPhrases(docText);
            } catch (Exception e) {
                //What if Article has No Sections
                String sectionArticle = "ARTICLE";
                System.out.println(e.getMessage());
            }
            DecimalFormat ff = new DecimalFormat("##");
            toBeTruncated = Double.valueOf(ff.format(toBeTruncated)) + 1.01;
        }
        skipFirstArtcile++;
    }

    Elastic.getDocument(client, "contract", "section", "1");
    Elastic.searchDocument(client, "contract", "section", "Lenders");
    Elastic.searchDocument(client, "contract", "section", "Negative Covenants");
    try {
        FileWriter file = new FileWriter("TableOfIndex.txt");
        file.write(tocOutput.toString());
        file.flush();
        file.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        FileWriter file = new FileWriter("Contract3_JSONFile.txt");
        file.write(obj.toString());
        file.flush();
        file.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        FileWriter file = new FileWriter("Contract1_KeyValueSections.txt");
        file.write(sectionOutput.toString());
        file.flush();
        file.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:at.tuwien.aic.Main.java

/**
 * Main entry point/* w  ww  . java 2 s.c  om*/
 *
 * @param args
 */
@SuppressWarnings("empty-statement")
public static void main(String[] args) throws IOException, InterruptedException {

    try {
        System.out.println(new java.io.File(".").getCanonicalPath());
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    TweetCrawler tc = null;

    try {
        tc = TweetCrawler.getInstance();
    } catch (UnknownHostException ex) {
        logger.severe("Could not connect to mongoDb");
        exitWithError(2);
        return;
    }

    int action;

    while (true) {
        action = getDecision("The following actions can be executed",
                new String[] { "Subscribe to topic", "Query topic", "Test preprocessing",
                        "Recreate the evaluation model", "Quit the application" },
                "What action do you want to execute?");

        switch (action) {
        case 1:
            tc.collectTweets(new DefaultTweetHandler() {
                @Override
                public boolean isMatch(String topic) {
                    return true;
                }
            }, getNonEmptyString(
                    "Which topic do you want to subscribe to (use spaces to specify more than one keyword)?")
                            .split(" "));

            System.out.println("Starting to collection tweets");
            System.out.println("Press enter to quit collecting");

            while (System.in.read() != 10)
                ;

            tc.stopCollecting();

            break;
        case 2:
            System.out.println("Enter tweet");
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String tweet = br.readLine();
            //double prediction = ClassifyTweet.classifyTweets(c, tweet, 2);
            System.exit(0);
            //classifyTopic();
            break;
        case 3:
            int subAction = getDecision("The following preprocessing steps are available",
                    new String[] { "Stop word removal", "Stemming", "Both" }, "What do you want to test?");

            switch (subAction) {
            case 1:
                stopWords();
                break;
            case 2:
                stem();
                break;
            case 3:
                stem(stopWords());
            default:
                break;
            }

            break;
        case 4:
            //ClassifyTweet.classifyTweetArff(c, "resources/unlabeled.arff", "resources/train.arff");
            ArrayList<String> tweets = new ArrayList<>();
            ArrayList<String> processedTweets = new ArrayList<>();

            //Positive Tweets
            tweets.add(
                    "#Office365 is the fastest growing business in Microsofts history, one out of four enterprise clients owns #Office365 in the past 12 months");
            tweets.add("oh yeah back to microsoft word it's great haha");
            tweets.add(
                    "Microsoft Visual Studio 2013 Ultimate: excellent tool, but a bit pricey at $13K - http://t.co/qbc4MHeOrF");
            tweets.add(
                    "Apple 'absolutely' plans to release new product types this year - Design Week: Design WeekApple 'absolutely' p... http://t.co/EK4rIbaHa0");
            tweets.add(
                    "RT @ReformedBroker: \"Apple can't innovate.\" Motherf***er you're watching a movie on a 4 ounce plate of glass.");
            tweets.add(
                    "What's the best brand of shoes?! Lol. There's too damn many, what do you prefer. Me is some Adidas.");
            tweets.add(
                    "I want ?? @AdorableWords: Tribal/Aztec pattern Nike free runs ?? http://t.co/WBxT8CNsPN?");
            tweets.add(
                    "I achieved the Streak Week trophy with my Nike+ FuelBand. #nikeplus http://t.co/OgtpRcoSvp");
            tweets.add("RT @DriveOfAthletes: Retweet for Nike! Favorite for UA! http://t.co/sKZ8hb27xH");

            //Neutral Tweets
            tweets.add("This site is giving away Free Microsoft Points #XBOX LIVE http://t.co/ZR1ythfqJ4");
            tweets.add(
                    "How To Save The World: 1. Open Microsoft Word. 2. In a size 12-36 font, type \"The World\". 3. Click save.");
            tweets.add(
                    "Microsoft Special Deals for Education: Microsoft special deals for Students, faculty and staff: http://t.co/Hf0b2ixPZa");
            tweets.add(
                    "Microsoft is about to take Windows XP off life support On April 8, Windows XP's life is coming to an end. On that d http://t.co/kcSf4uIqW4");
            tweets.add("Microsoft open sources its internet servers http://t.co/oLNTlVjE6Y");
            tweets.add(
                    "The Apple Macintosh computer turns 30 - ... http://t.co/CAfq09Jgn7 #CarlIcahn #IsaacsonIt #SteveJobs #WalterIsaacson");
            tweets.add(
                    "News Update| Samsung opens 60 dedicated stores in Europe with Carphone Warehouse http://t.co/1voh4yPMpN");
            tweets.add("I posted a new photo to Facebook http://t.co/fI40hwklUj");
            tweets.add(
                    "Brand New Men's ADIDAS VIGOR TR 3 Athletic Running shoes. Size: 11.5 http://t.co/oPuFoXLpeI");
            tweets.add("I just ran 2.58 mi with Nike+. http://t.co/pYLkhBxH4Y #nikeplus");
            tweets.add("Why is facebook still a thing");

            //Negative Tweets
            tweets.add("Thank God for microsoft programs.....");
            tweets.add(
                    "RT @verge: UK government once again threatens to ditch Microsoft Office http://t.co/vhvybI1GwI");
            tweets.add("Apple charge far too much for very poor phone cases");
            tweets.add("Here's Why Everyone Is Worried About Apple's iPhone Sales http://t.co/Eq3oPt76AG");
            tweets.add("Is Apple Ready to Disrupt Another Industry? http://t.co/07gedlN0cs via @zite");
            tweets.add(
                    "Tim Cook Officially Admits iPhone 5c Didnt Meet Expectations http://t.co/OdzGZOmdv7 #iPhone #Apple");
            tweets.add("@MushIsAJedi @HeyItsAmine i dont rlly like samsung that much");
            tweets.add("twitter facebook die shit");
            tweets.add(
                    "I am thinking of leaving Facebook for a while... To much spying going on.. I am sick and tired of thinking about... http:/)/t.co/ULydkDEube");
            tweets.add("RT @OfficialSheIdon: RIP Facebook, too many of our parents joined.");

            StopWordRemoval swr = new StopWordRemoval("resources/stopwords.txt");

            for (String t : tweets) {
                t = swr.processText(t);
                processedTweets.add(t);
            }

            for (int i = 0; i < 28; i++) {
                if (i != 4) {
                    ArrayList<Integer> results = ClassifyTweet.classifyTweets(processedTweets, i);

                    int correctCount = 0;
                    int positiveCorrect = 0;
                    int neutralCorrect = 0;
                    int negativeCorrect = 0;
                    int falsePosNeu = 0;
                    int falsePosNeg = 0;
                    int falseNeuPos = 0;
                    int falseNeuNeg = 0;
                    int falseNegNeu = 0;
                    int falseNegPos = 0;

                    for (int j = 0; j < 30; j++) {
                        int pred = results.get(j);

                        if (j >= 0 && j < 10) {
                            if (pred == 1) {
                                correctCount++;
                                positiveCorrect++;
                            } else if (pred == 0) {
                                falsePosNeu++;
                            } else if (pred == -1) {
                                falsePosNeg++;
                            }
                        } else if (j >= 10 && j < 20) {
                            if (pred == 0) {
                                correctCount++;
                                neutralCorrect++;
                            } else if (pred == 1) {
                                falseNeuPos++;
                            } else if (pred == -1) {
                                falseNeuNeg++;
                            }

                        } else if (j >= 20 && j < 30) {
                            if (pred == -1) {
                                correctCount++;
                                negativeCorrect++;
                            } else if (pred == 0) {
                                falseNegNeu++;
                            } else if (pred == 1) {
                                falseNegPos++;
                            }
                        }
                    }

                    System.out.println("Correct Predictions: " + correctCount + " / 30");
                    System.out.println("Correct Positive: " + positiveCorrect + " / 10");
                    System.out.println("Correct Neutral: " + neutralCorrect + " / 10");
                    System.out.println("Correct Negative: " + negativeCorrect + " / 10");

                    System.out.println("False Positive as Neutral: " + falsePosNeu);
                    System.out.println("False Positive as Negative: " + falsePosNeg);

                    System.out.println("False Neutral as Positive: " + falseNeuPos);
                    System.out.println("False Neutral as Negative: " + falseNeuNeg);

                    System.out.println("False Negative as Positive: " + falseNegPos);
                    System.out.println("False Negative as Neutral: " + falseNegNeu);
                }

            }

            exit();
        case 5:
            exit();
        }
    }
}

From source file:com.mmone.gpdati.allotment.reader.AllotmentFileReader.java

public static void main(String[] args) {
    try {/* w  w w. ja v a 2s .c om*/
        AllotmentLineProvvider afr = new AllotmentFileReader(
                "C:/svnprjects/mauro_netbprj/abs-ota-soapui-listener/test/FILE_DISPO__20160616.txt");

        List<String> l = afr.getLines();
        for (String s : l) {
            System.out.println(s);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.INFO,
                "skipping sync " + ex.getMessage());
    } catch (Exception ex) {
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.INFO,
                "skipping sync " + ex.getMessage());
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:comparetopics.CompareTwoGroupTopics.java

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    System.out.println("please input the path for File1: ");
    String filepath1 = sc.nextLine();
    System.out.println("please input the path for File2: ");
    String filepath2 = sc.nextLine();

    try {/* w w w. j  a  v  a2  s.  c  o m*/
        File file1 = new File(filepath1);
        File file2 = new File(filepath2);
        System.out.println("File1: " + filepath1);
        System.out.println("File2: " + filepath2);

        if (!file1.exists()) {
            System.out.println("File1 isn't exist");
        } else if (!file2.exists()) {
            System.out.println("File2 isn't exist");
        } else {
            try (InputStream in1 = new FileInputStream(file1.getPath());
                    BufferedReader reader1 = new BufferedReader(new InputStreamReader(in1))) {

                String line1 = null;
                int lineNr1 = -1;
                while ((line1 = reader1.readLine()) != null) {
                    ++lineNr1;

                    int lineNr2 = -1;
                    String line2 = null;
                    try (InputStream in2 = new FileInputStream(file2.getPath());
                            BufferedReader reader2 = new BufferedReader(new InputStreamReader(in2))) {
                        while ((line2 = reader2.readLine()) != null) {
                            ++lineNr2;
                            compareTwoGroups(line1, line2, lineNr1, lineNr2);
                        }
                    }
                    System.out.println();
                }
            }
        }

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

}

From source file:com.muni.fi.pa165.survive.rest.client.SurviveRESTClient.java

public static void main(String[] args) {

    File file = new File("err.txt");
    FileOutputStream fos = null;//from   w  ww. j  av  a 2s.  c o m
    try {
        fos = new FileOutputStream(file);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(SurviveRESTClient.class.getName()).log(Level.SEVERE, null, ex);
    }
    PrintStream ps = new PrintStream(fos);
    System.setErr(ps);

    CommandLineParser parser = new PosixParser();
    Options options = OptionsProvider.getInstance().getOptions();

    try {
        CommandLine line = parser.parse(options, args);
        List<String> validate = CommandLineValidator.validate(line);
        if (!validate.isEmpty()) {
            System.out.println("The following errors occured when parsing the command:");

            for (String string : validate) {
                System.out.println(string);
            }

            System.out.println("");
            printHelp(options);
            System.exit(1);
        }

        if (line.hasOption("h")) {
            printHelp(options);
            System.exit(0);
        }

        CustomRestService crudService;

        String operation = line.getOptionValue("o");

        // weapon mode
        if (line.hasOption("w")) {
            crudService = new WeaponServiceImpl();
            switch (operation) {
            case "C": {
                WeaponDto dto = DtoBuilder.getWeaponDto(line);
                Object byId = crudService.create(dto);
                printEntity(crudService.getResponse(), "Creating a weapon", byId);
                break;
            }
            case "R": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Object byId = crudService.getById(id);
                printEntity(crudService.getResponse(), "Reading a weapon with id " + id, byId);
                break;
            }
            case "U": {

                WeaponDto dto = DtoBuilder.getWeaponDto(line);
                Object byId = crudService.update(dto);
                printEntity(crudService.getResponse(), "Updating a weapon with id " + line.getOptionValue("i"),
                        byId);

                break;
            }
            case "D": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Response delete = crudService.delete(id);
                printEntity(crudService.getResponse(), "Deleting a weapon with id " + line.getOptionValue("i"),
                        crudService.getResponse().getStatusInfo());
                break;
            }
            case "A":
                List<AbstractDto> all = crudService.getAll();
                printEntities(crudService.getResponse(), "Reading all weapons", all);

                break;
            }
        } else if (line.hasOption("a")) {
            crudService = new AreaServiceImpl();
            switch (operation) {
            case "C": {
                AreaDto dto = DtoBuilder.getAreaDto(line);
                Object byId = crudService.create(dto);
                printEntity(crudService.getResponse(), "Creating an area", byId);
                break;
            }
            case "R": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Object byId = crudService.getById(id);
                printEntity(crudService.getResponse(), "Reading an area with id " + id, byId);
                break;
            }
            case "U": {
                AreaDto dto = DtoBuilder.getAreaDto(line);
                Object byId = crudService.update(dto);
                printEntity(crudService.getResponse(), "Updating an area with id " + line.getOptionValue("i"),
                        byId);
                break;
            }
            case "D": {
                Long id = Long.parseLong(line.getOptionValue("i"));
                Object byId = crudService.delete(id);
                printEntity(crudService.getResponse(), "Deleting an area with id " + line.getOptionValue("i"),
                        crudService.getResponse().getStatusInfo());
                break;
            }
            case "A":
                List<AbstractDto> all = crudService.getAll();
                printEntities(crudService.getResponse(), "Reading all areas", all);
                break;
            }
        } else {
            printHelp(options);
        }
    } catch (ParseException ex) {
        System.out.println(ex.getMessage());
        printHelp(options);
        System.exit(1);
    } catch (NumberFormatException ex) {
        System.out.println(ex.getMessage());
        printHelp(options);
        System.exit(2);
    } catch (MessageBodyProviderNotFoundException ex) {
        System.out.println("Couldn't connect to the server! Please make sure that the server side is running.");
        System.exit(3);
    } catch (ProcessingException ex) {
        System.out.println("Couldn't connect to the server! Please make sure that the server side is running.");
        System.exit(4);
    } catch (Exception ex) {
        System.out.println(
                "There was an error when connecting to the server. Please make sure that the server side is running.");
    }
}

From source file:br.com.itfox.beans.SendHtmlFormatedEmail.java

public static void main(String[] args) {
    try {/*from w  w w. j  a  va2 s .c om*/
        //new SendHtmlFormatedEmail().sendingHtml();
        String assunto = "";
        Mensagem msg = new Mensagem();
        // localizando a mensagem
        msg = new BusinessDelegate().getMensagem(new BigDecimal(61));
        assunto = msg.getAssunto();
        new SendHtmlFormatedEmail().sendingHtml("belchiorpalma@gmail.com", "Belchior", assunto, 2);
    } catch (Exception ex) {
        Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:downloadwolkflow.getWorkFlowList.java

public static void main(String args[]) {
    CloseableHttpClient httpclient = HttpClients.createDefault();
    String[] pageList = getPageList();
    System.out.println(pageList.length);
    for (int i = 1; i < pageList.length; i++) {
        System.out.println(pageList[i]);
        System.out.println("---------------------------------------------------------------------------");
        HttpGet httpget = new HttpGet(pageList[i]);
        try {//from   w w w .  j  a v  a2  s . c  o m
            HttpResponse response = httpclient.execute(httpget);
            String page = EntityUtils.toString(response.getEntity());
            Document mainDoc = Jsoup.parse(page);
            Elements resultList = mainDoc.select("div.resource_list_item");
            for (int j = 0; j < resultList.size(); j++) {
                Element workflowResult = resultList.get(j);
                Element detailInfo = workflowResult.select("div.main_panel").first().select("p.title.inline")
                        .first().select("a").first();
                String detailUrl = "http://www.myexperiment.org" + detailInfo.attributes().get("href")
                        + ".html";
                System.out.println(detailUrl);
                downloadWorkFlow(detailUrl, httpclient);
                Thread.sleep(1000);
            }
        } catch (IOException ex) {
            Logger.getLogger(getWorkFlowList.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(getWorkFlowList.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    try {
        httpclient.close();
    } catch (IOException ex) {
        Logger.getLogger(getWorkFlowList.class.getName()).log(Level.SEVERE, null, ex);
    }

}