Example usage for java.util.logging Logger getLogger

List of usage examples for java.util.logging Logger getLogger

Introduction

In this page you can find the example usage for java.util.logging Logger getLogger.

Prototype




@CallerSensitive
public static Logger getLogger(String name) 

Source Link

Document

Find or create a logger for a named subsystem.

Usage

From source file:evalita.q4faq.baseline.Index.java

/**
 * @param args the command line arguments
 *//*from   ww w .  j  a va 2  s.co  m*/
public static void main(String[] args) {
    try {
        if (args.length > 1) {
            Reader in = new FileReader(args[0]);
            IndexWriterConfig config = new IndexWriterConfig(Version.LATEST, new ItalianAnalyzer());
            IndexWriter writer = new IndexWriter(FSDirectory.open(new File(args[1])), config);
            Iterable<CSVRecord> records = CSVFormat.EXCEL.withHeader().withDelimiter(';').parse(in);
            for (CSVRecord record : records) {
                int id = Integer.parseInt(record.get("id"));
                String question = record.get("question");
                String answer = record.get("answer");
                String tag = record.get("tag");
                Document doc = new Document();
                doc.add(new StringField("id", String.valueOf(id), Field.Store.YES));
                doc.add(new TextField("question", question, Field.Store.NO));
                doc.add(new TextField("answer", answer, Field.Store.NO));
                doc.add(new TextField("tag", tag.replace(",", " "), Field.Store.NO));
                writer.addDocument(doc);
            }
            writer.close();
        } else {
            throw new IllegalArgumentException("Number of arguments not valid");
        }
    } catch (IOException | IllegalArgumentException ex) {
        Logger.getLogger(Index.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.bytecode.util.Crypto.java

public static void main(String args[]) {
    try {/*from w w  w .ja v  a2  s . c  o  m*/
        System.out.println("Hello world:" + Crypto.decrypt256(VANSO_KEY, "eQDUrpkbc1R0IMw/hGbWPK4="));
    } catch (Exception ex) {
        Logger.getLogger(Crypto.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:es.jamisoft.comun.utils.cipher.Cifrado3DES.java

public static void main(String args[]) {
    try {//from w w w  . j  a  v  a2 s.c o  m
        CifradoDES crypt = new CifradoDES();
        String encrypted = crypt.cifra("Adios");

        System.out.println("Encrypted: " + encrypted);
        System.out.println("Decrypted: " + crypt.descifra(encrypted));
    } catch (EncoderException ex) {
        Logger.getLogger(Cifrado3DES.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:edu.fullerton.timeseriesapp.TimeSeriesApp.java

/**
 * @param args the command line arguments
 *///from w  w w . j a va  2s  . c om
public static void main(String[] args) {
    int stat;
    startMs = System.currentTimeMillis();
    try {
        TimeSeriesApp me = new TimeSeriesApp();

        // decode command line and set parameters
        boolean doit = me.processArgs(args);

        // generate image
        if (doit) {
            stat = me.doPlot();
        } else {
            stat = 10;
        }
    } catch (Exception ex) {
        Logger.getLogger(TimeSeriesApp.class.getName()).log(Level.SEVERE, null, ex);
        stat = 11;
    }
    // timing info
    double elapsedSec = (System.currentTimeMillis() - startMs) / 1000.;

    System.out.format("Run time: %1$.2f sec%n", elapsedSec);
    System.exit(stat);

}

From source file:malware_classification.Malware_Classification.java

/**
 * @param args the command line arguments. Order is malicious_filename,
 * benign filename, (optional) bin_size/*ww  w  .  j  ava 2  s.c o m*/
 */
public static void main(String[] args) {
    String malicious_file_path = args[0];
    String benign_file_path = args[1];
    int curr_bin_size;
    if (args.length > 2) {
        curr_bin_size = Integer.parseInt(args[2]);
    } else {
        curr_bin_size = -1;
    }
    String pid_str = ManagementFactory.getRuntimeMXBean().getName();
    logger.setLevel(Level.CONFIG);
    logger.log(Level.INFO, pid_str);
    boolean found_file = false;
    String output_base = "std_output";
    File output_file = null;
    for (int i = 0; !found_file; i++) {
        output_file = new File(output_base + i + ".txt");
        found_file = !output_file.exists();
    }

    FileHandler fh = null;
    try {
        fh = new FileHandler(output_file.getAbsolutePath());
    } catch (IOException ex) {
        Logger.getLogger(Malware_Classification.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(Malware_Classification.class.getName()).log(Level.SEVERE, null, ex);
    }
    logger.addHandler(fh);
    logger.info("Writing output in " + output_file.getAbsolutePath());

    Malware_Classification classifier = new Malware_Classification(malicious_file_path, benign_file_path,
            curr_bin_size);
    //        classifier.run_tests();
}

From source file:com.hurence.logisland.util.string.Anonymizer.java

public static void main(String[] args) {
    try {//  w  w w .  j  a  va  2 s .co m

        Anonymizer anon = new Anonymizer();

        String ip1 = "123.90.3.23";
        String ip2 = "123.90.3.24";
        System.out.println(anon.anonymize(ip1));

        System.out.println(anon.anonymize(ip1));
        System.out.println(anon.anonymize(ip2));

        String url = "http://www.google.com/support/enterprise/static/gsa/docs/admin/70/gsa_doc_set/integrating_apps/images/google_logo.png";

        System.out.println(anon.anonymizeKeepExtension(url));

    } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
        Logger.getLogger(Anonymizer.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:at.tuwien.ifs.somtoolbox.apps.helper.VectorFileSubsetGenerator.java

public static void main(String[] args) throws IOException, SOMToolboxException {
    // register and parse all options
    JSAPResult config = OptionFactory.parseResults(args, OPTIONS);

    String inputFileName = AbstractOptionFactory.getFilePath(config, "input");
    String classInformationFileName = AbstractOptionFactory.getFilePath(config, "classInformationFile");
    String outputFileName = AbstractOptionFactory.getFilePath(config, "output");

    String[] keepClasses = config.getStringArray("classList");

    boolean skipInstanceNames = false;// config.getBoolean("skipInstanceNames");
    boolean skipInputsWithoutClass = false;// config.getBoolean("skipInputsWithoutClass");
    boolean tabSeparatedClassFile = false;// config.getBoolean("tabSeparatedClassFile");

    String inputFormat = config.getString("inputFormat");
    if (inputFormat == null) {
        inputFormat = InputDataFactory.detectInputFormatFromExtension(inputFileName, "input");
    }/*from w w  w .ja v a2s .c o  m*/
    String outputFormat = config.getString("outputFormat");
    if (outputFormat == null) {
        outputFormat = InputDataFactory.detectInputFormatFromExtension(outputFileName, "output");
    }

    InputData data = InputDataFactory.open(inputFormat, inputFileName);
    if (classInformationFileName != null) {
        SOMLibClassInformation classInfo = new SOMLibClassInformation(classInformationFileName);
        data.setClassInfo(classInfo);
    }
    if (data.classInformation() == null) {
        throw new SOMToolboxException("Need to provide a class information file.");
    }

    Logger.getLogger("at.tuwien.ifs.somtoolbox")
            .info("Retaining elements of classes: " + Arrays.toString(keepClasses));

    ArrayList<InputDatum> subData = new ArrayList<InputDatum>();
    for (int i = 0; i < data.numVectors(); i++) {
        InputDatum datum = data.getInputDatum(i);
        String className = data.classInformation().getClassName(datum.getLabel());
        System.out.println(datum.getLabel() + "=>" + className);
        if (ArrayUtils.contains(keepClasses, className)) {
            subData.add(datum);
        }
    }

    InputData subset = new SOMLibSparseInputData(subData.toArray(new InputDatum[subData.size()]),
            data.classInformation());
    InputDataWriter.write(outputFileName, subset, outputFormat, tabSeparatedClassFile, skipInstanceNames,
            skipInputsWithoutClass);
}

From source file:com.canoo.dolphin.todo.client.ToDoClient.java

public static void main(String[] args) {
    Logger OD_LOGGER = Logger.getLogger("org.opendolphin");
    OD_LOGGER.setLevel(Level.SEVERE);

    Application.launch(args);/*  ww w  .  j  av  a2 s.c  o m*/
}

From source file:business.management.system.TeamStatistics.java

/**
 * @param args the command line arguments
 *//*from ww  w.  j  av a 2  s. c o m*/
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(TeamStatistics.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(TeamStatistics.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(TeamStatistics.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(TeamStatistics.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                new TeamStatistics().setVisible(true);
            } catch (SQLException ex) {
                Logger.getLogger(TeamStatistics.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

From source file:my.yelp.populate.java

public static void main(String[] args)
        throws FileNotFoundException, ParseException, IOException, java.text.ParseException {
    try {/*from  w w  w  .  j a  v a 2  s . c  o  m*/

        DbConnection A1 = new DbConnection();
        Connection con = A1.getConnection();

        JSONParser jsonParser;
        jsonParser = new JSONParser();

        Object obj1 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_user.json"));
        Object obj2 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_business.json"));
        Object obj3 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_review.json"));
        Object obj4 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_checkin.json"));

        JSONArray jsonArray1;
        jsonArray1 = (JSONArray) obj1;

        JSONArray jsonArray2;
        jsonArray2 = (JSONArray) obj2;

        JSONArray jsonArray3;
        jsonArray3 = (JSONArray) obj3;

        JSONArray jsonArray4;
        jsonArray4 = (JSONArray) obj4;

        // yelp_user
        String yelping_since, name1, user_id, type1;
        Long review_count1, fans;
        Double average_stars;
        Statement stmt;

        stmt = con.createStatement();
        stmt.executeUpdate("Delete from N_User");

        for (int i = 0; i < (jsonArray1.size()); i++)

        {
            JSONObject jsonObject = (JSONObject) jsonArray1.get(i);
            yelping_since = (String) jsonObject.get("yelping_since") + "-01";

            JSONArray friends = (JSONArray) jsonObject.get("friends");
            int friends_size = friends.size();

            review_count1 = (Long) jsonObject.get("review_count");
            name1 = (String) jsonObject.get("name");
            user_id = (String) jsonObject.get("user_id");
            fans = (Long) jsonObject.get("fans");
            average_stars = (Double) jsonObject.get("average_stars");
            type1 = (String) jsonObject.get("type");

            try (PreparedStatement pstmt1 = con.prepareStatement(
                    "Insert INTO N_User(yelping_since,friends_size,review_count,name,user_id,fans,average_stars,type) VALUES(?,?,?,?,?,?,?,?)")) {

                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                java.util.Date myDate = format.parse(yelping_since);

                pstmt1.setDate(1, new java.sql.Date(myDate.getTime()));
                pstmt1.setInt(2, friends_size);
                pstmt1.setLong(3, review_count1);
                pstmt1.setString(4, name1);
                pstmt1.setString(5, user_id);
                pstmt1.setLong(6, fans);
                pstmt1.setDouble(7, average_stars);
                pstmt1.setString(8, type1);
                pstmt1.executeUpdate();
            } catch (java.text.ParseException ex) {
                Logger.getLogger(populate.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        //yelp_business

        String business_id, address, city, state, name, type_business;

        Double stars;

        for (int i = 0; i < jsonArray2.size(); i++) {
            JSONObject jsonObject = (JSONObject) jsonArray2.get(i);
            business_id = (String) jsonObject.get("business_id");
            address = (String) jsonObject.get("full_address");
            city = (String) jsonObject.get("city");
            state = (String) jsonObject.get("state");
            name = (String) jsonObject.get("name");
            stars = (Double) jsonObject.get("stars");
            type_business = (String) jsonObject.get("type");

            try (PreparedStatement pstmt2 = con.prepareStatement(
                    "Insert INTO N_Business(business_id,address,city,state,name,stars,type_business) VALUES(?,?,?,?,?,?,?)")) {
                pstmt2.setString(1, business_id);
                pstmt2.setString(2, address);
                pstmt2.setString(3, city);
                pstmt2.setString(4, state);
                pstmt2.setString(5, name);
                pstmt2.setDouble(6, stars);
                pstmt2.setString(7, type_business);
                pstmt2.executeUpdate();
                pstmt2.close();
            }

        }

        //Category Table
        String[] categories = { "Active Life", "Arts & Entertainment", "Automotive", "Car Rental", "Cafes",
                "Beauty & Spas", "Convenience Stores", "Dentists", "Doctors", "Drugstores", "Department Stores",
                "Education", "Event Planning & Services", "Flowers & Gifts", "Food", "Health & Medical",
                "Home Services", "Home & Garden", "Hospitals", "Hotels & travel", "Hardware stores", "Grocery",
                "Medical Centers", "Nurseries & Gardening", "Nightlife", "Restaurants", "Shopping",
                "Transportation" };

        JSONArray category;
        String[] individual_category = new String[100];
        int count = 0, flag = 0, m = 0, n = 0;
        String[] business_category = new String[50];
        String[] subcategory = new String[50];

        for (int i = 0; i < jsonArray2.size(); i++) {
            JSONObject jsonObject3 = (JSONObject) jsonArray2.get(i);
            String business_id2 = (String) jsonObject3.get("business_id");
            category = (JSONArray) jsonObject3.get("categories");
            for (int j = 0; j < category.size(); j++) {
                individual_category[j] = (String) category.get(j);
                count = count + 1;
            }
            for (int k = 0; k < count; k++) {
                for (String categorie : categories) {

                    if (individual_category[k].equals(categorie)) {
                        flag = 1;
                        break;
                    }
                }
                if (flag == 1) {
                    business_category[m] = individual_category[k];
                    m = m + 1;
                    flag = 0;
                } else {
                    subcategory[n] = individual_category[k];
                    n = n + 1;
                }
            }
            for (int p = 0; p < m; p++) {
                for (int q = 0; q < n; q++) {
                    try (PreparedStatement pstmt3 = con.prepareStatement(
                            "INSERT INTO N_Category(business_id,category,subcategory) VALUES(?,?,?)")) {
                        pstmt3.setString(1, business_id2);
                        pstmt3.setString(2, business_category[p]);
                        pstmt3.setString(3, subcategory[q]);
                        pstmt3.executeUpdate();

                    }
                }
            }
            count = 0;
            m = 0;
            n = 0;
        }

        //yelp_review

        String user_id3, review_id, type3, business_id3, text, text1, review_date;
        Long stars3;
        int votes = 0;
        Integer no_votes;

        JSONObject votes_info;
        Set<String> keys;

        for (int i = 0; i < jsonArray3.size(); i++) {
            JSONObject jsonObject = (JSONObject) jsonArray3.get(i);

            votes_info = (JSONObject) jsonObject.get("votes");
            keys = votes_info.keySet();
            for (String r_key : keys) {
                votes = (int) (votes + (Long) votes_info.get(r_key));
            }
            no_votes = toIntExact(votes);
            user_id3 = (String) jsonObject.get("user_id");

            review_id = (String) jsonObject.get("review_id");
            business_id3 = (String) jsonObject.get("business_id");
            review_date = (String) jsonObject.get("date");
            text1 = (String) jsonObject.get("text");
            text = text1.substring(0, Math.min(1000, text1.length()));
            stars3 = (Long) jsonObject.get("stars");
            type3 = (String) jsonObject.get("type");

            try (PreparedStatement pstmt4 = con.prepareStatement(
                    "Insert INTO N_Review(no_votes,user_id,review_id,business_id,review_date,text,stars,type) VALUES(?,?,?,?,?,?,?,?)")) {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                java.util.Date myDate = format.parse(review_date);

                pstmt4.setInt(1, no_votes);
                pstmt4.setString(2, user_id3);
                pstmt4.setString(3, review_id);
                pstmt4.setString(4, business_id3);
                pstmt4.setDate(5, new java.sql.Date(myDate.getTime()));
                pstmt4.setString(6, text);
                pstmt4.setLong(7, stars3);
                pstmt4.setString(8, type3);
                pstmt4.executeUpdate();
                pstmt4.close();
            }

        }

        //Checkin_Info
        JSONObject checkin_info;
        String business_id4;
        Long check_in_count;
        Set<String> keys1;
        String[] timing = new String[10];
        int n1 = 0, time, hour;

        //Inserting into checkin_info
        for (int i = 0; i < jsonArray4.size(); i++) {
            JSONObject jsonObject4 = (JSONObject) jsonArray4.get(i);
            checkin_info = (JSONObject) jsonObject4.get("checkin_info");
            business_id4 = (String) jsonObject4.get("business_id");
            keys1 = checkin_info.keySet();

            for (String key : keys1) {
                check_in_count = (Long) checkin_info.get(key);
                for (String x : key.split("-")) {
                    timing[n1] = x;
                    n1 = n1 + 1;
                }
                n1 = 0;
                hour = Integer.parseInt(timing[0]);
                time = Integer.parseInt(timing[1]);

                try (PreparedStatement pstmt5 = con.prepareStatement(
                        "INSERT INTO check_info(business_id,hour,day,check_in_count)VALUES(?,?,?,?)")) {
                    pstmt5.setString(1, business_id4);
                    pstmt5.setInt(2, hour);
                    pstmt5.setInt(3, time);
                    pstmt5.setLong(4, check_in_count);
                    pstmt5.executeUpdate();
                }
            }

        }

        con.close();

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

}