List of usage examples for java.util.logging Level SEVERE
Level SEVERE
To view the source code for java.util.logging Level SEVERE.
Click Source Link
From source file:gpxparser.GpxParser.java
/** * @param args the command line arguments *//* w ww . jav a 2 s . co m*/ public static void main(String[] args) { File input = new File("/home/yonseca/4.gpx"); Track track = new Track(); try { Document doc = Jsoup.parse(input, "UTF-8"); //System.out.println(doc.text()); Elements trackData = doc.getElementsByTag("trk"); Elements trackName = trackData.select("name"); track.setName(trackName.text()); Elements trkPt = trackData.select("trkseg").select("trkpt"); for (Iterator<Element> iterator = trkPt.iterator(); iterator.hasNext();) { Element dataPoint = iterator.next(); Double lat = NumberUtils.toDouble(dataPoint.attr("lat")); Double lon = NumberUtils.toDouble(dataPoint.attr("lon")); Double altitude = NumberUtils.toDouble(dataPoint.select("ele").text()); track.addPoint(lat, lon, altitude); } System.out.println(""); } catch (IOException ex) { Logger.getLogger(GpxParser.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gomokuserver.GomokuServer.java
/** * @param args the command line arguments * @throws java.lang.InterruptedException *///w ww .j a va 2s . c o m public static void main(String[] args) throws InterruptedException { if (args.length != 1) { System.out.println("Run with listen portno as argument"); return; } int portno = Integer.parseInt(args[0]); ServerSocket sc; try { System.out.print("Creating socket bound to " + portno + " ... "); sc = new ServerSocket(portno); System.out.println("DONE"); } catch (IOException ex) { System.out.println(ex.getMessage()); return; } FrontOffice fo = new FrontOffice(); Lobby lb = new Lobby(); fo.setReferalLobby(lb); fo.start(); lb.start(); while (!interrupted()) { try { Socket playersocket = sc.accept(); playersocket.setKeepAlive(true); System.out.println("Received client from " + playersocket.getInetAddress()); fo.handle(playersocket); } catch (IOException ex) { Logger.getLogger(GomokuServer.class.getName()).log(Level.SEVERE, null, ex); } } fo.interrupt(); lb.interrupt(); fo.join(); lb.join(); }
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 www . j a v a 2s . 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:Logica.prueba.java
public static void main(String[] args) { try {// w ww. j av a 2s .c om prueba prueba = new prueba(); } catch (Exception ex) { Logger.getLogger(prueba.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.my.spring.batch.java.config.demo.Main.java
public static void main(String[] args) { //System.exit(SpringApplication.exit(SpringApplication.run(MyBatchConfiguration.class, args))); logger.log(Level.INFO, "extracting job parameters from command line arguments {0}", args); JobParameters jobParameters = parseJobParameters(args); String basePackage = Main.class.getPackage().getName(); logger.log(Level.INFO, "scanning {0} for classes with bean definitions", basePackage); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(basePackage); Job job1 = context.getBean("job1", Job.class); JobLauncher jobLauncher = context.getBean(JobLauncher.class); try {/*from w w w . jav a2 s.c o m*/ JobExecution jobExecution = jobLauncher.run(job1, jobParameters); logger.log(Level.INFO, "job execution {0} ended with status: {1}", new Object[] { jobExecution.getId(), jobExecution.getStatus() }); } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); } }
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 ava2s.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:de.wpsverlinden.dupfind.DupFind.java
public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("AppConfig.xml"); DupFind app = (DupFind) ctx.getBean("dupFind"); try {// w w w . ja v a 2s.c o m app.run(); } catch (IOException ex) { Logger.getLogger(DupFind.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.sociesc.findasmartphonespark.Main.java
public static void main(String[] args) { String apiPrefix = "api/v1/"; //setIpAddress("192.168.56.1"); setPort(9010);/*from w w w . ja v a2 s. c om*/ try { Logger.getLogger(Main.class.getName()).log(Level.INFO, "Criando banco de dados"); DatabaseUtils.seedDatabase(); } catch (SQLException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } Dao<User> userDao = new Dao(User.class); get(apiPrefix + "/hello/:name", (request, response) -> { ObjectMapper objectMapper = new ObjectMapper(); /*ArrayList<AccessPoint> arrayAp = new ArrayList<AccessPoint>(); for (int i = 0; i < 10; i++) { AccessPoint ap = new AccessPoint(); ap.setBSSID("AP" + i); ap.setSSID("00:00:00:0" + i); ap.setRSSI(-50 + i); ap.setSala("Sala" + i); arrayAp.add(ap); //System.out.println("Nome: " + ap.getBSSID() + " - Mac: " + ap.getSSID() + " - Sinal: " + ap.getRSSI()); } String retornoJson = rwJson.writeJson(arrayAp);*/ //objectMapper.readValue(URLDecoder.decode(request.params(":name"), "UTF-8"), new TypeReference(String("lol"))); ArrayList<AccessPoint> arrayAp = null; try { arrayAp = rwJson.readJson(URLDecoder.decode(request.params(":name"), "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return arrayAp.get(0).getBSSID(); //return "Hello: " + request.params(":name"); //return arrayAp[0].get; }); post(apiPrefix + "/findUser/:data", (request, response) -> { String userId = request.params(":data"); ArrayList<AccessPoint> aps = rwJson.readJson(userId.toString()); /*JsonObject json = new JsonObject(); try { json = JsonObject.readFrom(request.params(":data")); } catch (Exception ex) { System.out.println("erro no json:\n" + ex.getMessage()); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); json.add("error", ex.getMessage()); response.status(500); }*/ try { for (int i = 0; i < aps.size(); i++) { System.out.println("Nome: " + aps.get(i).getBSSID() + " - Mac: " + aps.get(i).getSSID() + " - Sinal: " + aps.get(i).getRSSI() + " - Sala: " + aps.get(i).getSala()); } } catch (Exception ex) { System.out.println("erro no json:\n" + ex.getMessage()); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); //json.add("error", ex.getMessage()); response.status(500); return ex.getMessage(); } return userId.toString(); }); /*post(apiPrefix + "/findUser/", (request, response) ->{ JsonObject json = new JsonObject(); // Informaes do roteador/AP String[] BSSID; // basic service set identifier - nome da conexo String[] SSID; // service set identifier - identificador nico da conexo int[] RSSI; // received signal strength indicator - potencia do sinal (-87 a -32) String sala; String jsonBody = request.body(); JsonObject reqJson = JsonObject.readFrom(jsonBody); JsonObject wifiJson = reqJson.get("wifi").asObject(); System.out.println("reqJson.size()" + reqJson.size() + "\nwifiJson.size()" + wifiJson.size()); RSSI = new int[wifiJson.size()]; BSSID = new String[wifiJson.size()]; SSID = new String[wifiJson.size()]; try{ for (int i = 0; i < wifiJson.size(); i++) { // recebe informaes das conexes encontradas BSSID[i] = wifiJson.get("BSSID").asString(); SSID[i] = wifiJson.get("SSID").asString(); RSSI[i] = wifiJson.get("RSSI").asInt(); } return json.toString(); }catch(Exception ex){ System.out.println("erro no json:\n" + ex.getMessage()); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); json.add("error", ex.getMessage()); response.status(500); } return json.toString(); });*/ get(apiPrefix + "/users", (request, response) -> { JsonObject json = new JsonObject(); request.params(); try { List<User> users = userDao.findAll(); JsonArray usersJson = new JsonArray(); for (User u : users) { JsonObject uJson = new JsonObject(); uJson.add("id", u.getId()); uJson.add("name", u.getName()); uJson.add("email", u.getEmail()); usersJson.add(uJson); } json.add("users", usersJson); } catch (SQLException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); json.add("error", ex.getMessage()); response.status(500); } return json.toString(); }); /*get(apiPrefix + "/users/:id", (request, response) -> { Long userId = Long.parseLong(request.params(":id")); JsonObject json = new JsonObject(); try{ User user = userDao.findById(userId); if(user == null){ json.add("error", "user not found"); response.status(404); return json.toString(); } JsonObject userJson = new JsonObject(); userJson.add("id", user.getId()); userJson.add("name", user.getName()); userJson.add("email", user.getEmail()); json.add("user", userJson); return json.toString(); }catch(Exception ex){ Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); json.add("error", ex.getMessage()); response.status(500); } return json.toString(); });*/ delete(apiPrefix + "/users/:id", (request, response) -> { Long userId = Long.parseLong(request.params(":id")); JsonObject json = new JsonObject(); try { userDao.removeById(userId); json.add("message", "user removed"); response.status(200); return json.toString(); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); json.add("error", ex.getMessage()); response.status(500); } return json.toString(); }); put(apiPrefix + "/users/:id", (request, response) -> { Long userId = Long.parseLong(request.params(":id")); JsonObject json = new JsonObject(); try { String jsonBody = request.body(); JsonObject reqJson = JsonObject.readFrom(jsonBody); JsonObject userJson = reqJson.get("user").asObject(); String name = userJson.get("name") != null ? userJson.get("name").asString() : null; String email = userJson.get("email") != null ? userJson.get("email").asString() : null; String password = userJson.get("password") != null ? userJson.get("password").asString() : null; User user = userDao.findById(userId); if (name != null) user.setName(name); if (email != null) user.setEmail(email); if (password != null) { String passwordDigest = DatabaseUtils.criptPass(password); user.setPasswordDigest(passwordDigest); } userDao.update(user); JsonObject resUserJson = new JsonObject(); resUserJson.add("id", user.getId()); resUserJson.add("name", user.getName()); resUserJson.add("email", user.getEmail()); json.add("user", resUserJson); return json.toString(); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); json.add("error", ex.getMessage()); response.status(500); } return json.toString(); }); post(apiPrefix + "/users", (request, response) -> { JsonObject json = new JsonObject(); try { String jsonBody = request.body(); JsonObject reqJson = JsonObject.readFrom(jsonBody); JsonObject userJson = reqJson.get("user").asObject(); User user = new User(); user.setName(userJson.get("name").asString()); user.setEmail(userJson.get("email").asString()); user.setPasswordDigest(DatabaseUtils.criptPass("tempPass")); userDao.create(user); JsonObject resUserJson = new JsonObject(); resUserJson.add("id", user.getId()); resUserJson.add("name", user.getName()); resUserJson.add("email", user.getEmail()); resUserJson.add("passwordDigest", user.getPasswordDigest()); json.add("user", resUserJson); return json.toString(); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); json.add("error", ex.getMessage()); response.status(500); } return json.toString(); }); }
From source file:com.seavus.wordcountermaven.WordCounter.java
/** * @param args the command line arguments * @throws java.io.FileNotFoundException *///from ww w .j a va2 s . c o m 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 {/*from w w w. j a va2 s . com*/ 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); } }