List of usage examples for java.util.logging Logger getLogger
@CallerSensitive public static Logger getLogger(String name)
From source file:com.opensearchserver.textextractor.Main.java
public static void main(String[] args) throws IOException, ParseException { Logger.getLogger("").setLevel(Level.WARNING); Options options = new Options(); options.addOption("h", "help", false, "print this message"); options.addOption("p", "port", true, "TCP port"); CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar target/oss-text-extractor.jar", options); return;//from w w w. j a va2s . com } int port = cmd.hasOption("p") ? Integer.parseInt(cmd.getOptionValue("p")) : 9091; UndertowJaxrsServer server = new UndertowJaxrsServer() .start(Undertow.builder().addHttpListener(port, "localhost")); server.deploy(Main.class); }
From source file:com.rest.samples.getImagePrintJPanel.java
public static void main(String[] args) { // TODO code application logic here String url = "https://api.adorable.io/avatars/eyes5"; try {//from w w w. jav a 2 s.c o m HttpClient hc = HttpClientBuilder.create().build(); HttpGet getMethod = new HttpGet(url); getMethod.addHeader("accept", "application/png"); HttpResponse res = hc.execute(getMethod); if (res.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("Failed : HTTP eror code: " + res.getStatusLine().getStatusCode()); } InputStream is = res.getEntity().getContent(); Image image = ImageIO.read(is); JFrame frame = new JFrame(); JLabel label = new JLabel(new ImageIcon(image)); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } catch (IOException ex) { Logger.getLogger(SamplesUseHttpclient.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.cloudfoundry.workers.stocks.integration.client.Main.java
public static void main(String args[]) throws Throwable { AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(); annotationConfigApplicationContext.getEnvironment().setActiveProfiles(isCloudFoundry() ? "cloud" : "local"); annotationConfigApplicationContext.scan(ClientConfiguration.class.getPackage().getName()); annotationConfigApplicationContext.refresh(); StockClientGateway clientGateway = annotationConfigApplicationContext.getBean(StockClientGateway.class); Logger log = Logger.getLogger(Main.class.getName()); String symbol = "VMW"; StockSymbolLookup lookup = clientGateway.lookup(symbol); log.info("client: retrieved stock information: " + ToStringBuilder.reflectionToString(lookup)); }
From source file:com.rest.samples.getImage.java
public static void main(String[] args) { // TODO code application logic here String url = "https://api.adorable.io/avatars/eyes1"; try {/*from ww w. j av a2 s .c om*/ HttpClient hc = HttpClientBuilder.create().build(); HttpGet getMethod = new HttpGet(url); getMethod.addHeader("accept", "application/png"); HttpResponse res = hc.execute(getMethod); if (res.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("Failed : HTTP eror code: " + res.getStatusLine().getStatusCode()); } InputStream is = res.getEntity().getContent(); OutputStream os = new FileOutputStream(new File("img.png")); int read = 0; byte[] bytes = new byte[2048]; while ((read = is.read(bytes)) != -1) { os.write(bytes, 0, read); } is.close(); os.close(); } catch (IOException ex) { Logger.getLogger(SamplesUseHttpclient.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Logica.prueba.java
public static void main(String[] args) { try {/* w w w .ja v a 2s .com*/ prueba prueba = new prueba(); } catch (Exception ex) { Logger.getLogger(prueba.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:de.wpsverlinden.dupfind.DupFind.java
public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("AppConfig.xml"); DupFind app = (DupFind) ctx.getBean("dupFind"); try {//from ww w. jav a2 s . co m app.run(); } catch (IOException ex) { Logger.getLogger(DupFind.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.seavus.wordcountermaven.WordCounter.java
/** * @param args the command line arguments * @throws java.io.FileNotFoundException *///from w w w . j av a 2 s .com public static void main(String[] args) throws FileNotFoundException { InputStream fileStream = WordCounter.class.getClassLoader().getResourceAsStream("test.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fileStream)); Map<String, Integer> wordMap = new HashMap<>(); String line; boolean tokenFound = false; try { while ((line = br.readLine()) != null) { String[] tokens = line.trim().split("\\s+"); //trims surrounding whitespaces and splits lines into tokens for (String token : tokens) { for (Map.Entry<String, Integer> entry : wordMap.entrySet()) { if (StringUtils.equalsIgnoreCase(token, entry.getKey())) { wordMap.put(entry.getKey(), (wordMap.get(entry.getKey()) + 1)); tokenFound = true; } } if (!token.equals("") && !tokenFound) { wordMap.put(token.toLowerCase(), 1); } tokenFound = false; } } br.close(); } catch (IOException ex) { Logger.getLogger(WordCounter.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("string : " + "frequency\r\n" + "-------------------"); //prints out each unique word (i.e. case-insensitive string token) and its frequency to the console for (Map.Entry<String, Integer> entry : wordMap.entrySet()) { System.out.println(entry.getKey() + " : " + entry.getValue()); } }
From source file:APIRequest.java
public static void main(String[] args) { String orderID = "Testing Order-01"; int grossAmount = 150000; JSONObject jso = new JSONObject(); JSONObject transactionDetails = new JSONObject(); try {//w ww. ja v a 2 s.c o m transactionDetails.put("order_id", orderID); transactionDetails.put("gross_amount", grossAmount); jso.put("transaction_details", transactionDetails); System.out.println(jso.toString()); System.out.println(jso.getJSONObject("transaction_details").get("order_id")); } catch (JSONException ex) { Logger.getLogger(APIRequest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:hotelregistration.HotelRegistration.java
/** * @param args the command line arguments *//*w w w. j av a 2s . c om*/ public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); DBConnection dbCon = new DBConnection(); dbCon.getConnetion(); try { Statement st = dbCon.getConnetion().createStatement(); ResultSet rs = st.executeQuery("SELECT NAME, ADDRESS FROM HOTEL"); Hotel hotel = (Hotel) context.getBean("hotel"); while (rs.next()) { hotel.setName(rs.getString("name")); hotel.setAddress(rs.getString("address")); System.out.println("1. Nombre: " + hotel.getName() + ", Direccion: " + hotel.getAddress()); } HotelDao hotelDao = (HotelDao) context.getBean("hotelDao"); Hotel hotel1 = hotelDao.findHotel("Moon"); Hotel hotel2 = new Hotel(); hotel2.setName("Jupiter"); hotel2.setAddress("Jupiter"); hotelDao.insertHotel(hotel2); System.out.println("2. Nombre: " + hotel1.getName() + ", Direccion: " + hotel1.getAddress()); } catch (SQLException ex) { Logger.getLogger(HotelRegistration.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:MyTest.DownloadFileTest.java
public static void main(String args[]) { CloseableHttpClient httpclient = HttpClients.createDefault(); String url = "http://www.myexperiment.org/workflows/16/download/Pathways_and_Gene_annotations_for_QTL_region-v7.t2flow?version=7"; System.out.println(url.charAt(50)); HttpGet httpget = new HttpGet(url); HttpEntity entity = null;//from www . j a va2 s . c o m try { HttpResponse response = httpclient.execute(httpget); entity = response.getEntity(); if (entity != null) { InputStream is = entity.getContent(); String filename = "testdata/Pathways_and_Gene_annotations_for_QTL_region-v7.t2flow"; BufferedInputStream bis = new BufferedInputStream(is); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(filename))); int readedByte; while ((readedByte = bis.read()) != -1) { bos.write(readedByte); } bis.close(); bos.close(); } httpclient.close(); } catch (IOException ex) { Logger.getLogger(DownloadFileTest.class.getName()).log(Level.SEVERE, null, ex); } }