java

How to display topics using Kafka Clients in Java?

筅森魡賤 提交于 2021-02-20 04:55:27
问题 public static void main(String [] args){ Properties config = new Properties(); config.put(AdminClientConfig.BOOTSRAP._SERVERS_CONFIG, "mybroker.ip.address:9092"); AdminClient admin = AdminClient.create(config); ListTopicsResult ltr = admin.listTopics().names().get(); } I am catching an ExecutionException with the error messages: org.apache.kafka.common.errors.TimeoutException: Call(callName:listTopics, deadlineMs=1599813311360, tries=1, nextAllowedTryMs=-9223372034707292162) timed out at

Java won't recognize file in JAR

橙三吉。 提交于 2021-02-20 04:55:27
问题 I have a .csv database file inside my java program's JAR file. The program works fine in NetBeans IDE before I package it, but once I do, it refuses to believe the file is in it, even though I had it print out the path where it was looking and unzipped the JAR to be sure I told it to look in the right place. How do I make Java see this? try { String path = Main.class.getResource("/items.csv").getPath(); db = new java.io.File(path); loadValues(db); } catch (java.io.FileNotFoundException ex1) {

Java NLP: Extracting Indicies When Tokenizing Text

六眼飞鱼酱① 提交于 2021-02-20 04:54:46
问题 When tokenizing a string of text, I need to extract the indexes of the tokenized words. For example, given: "Mary didn't kiss John" I would need something like: [(Mary, 0), (did, 5), (n't, 8), (kiss, 12), (John, 17)] Where 0, 5, 8, 12 and 17 correspond to the index (in the original string) where the token began. I cannot rely on just whitespace, since some words become 2 tokens. Further, I cannot just search for the token in the string, since the word likely will appear multiple times. One

Caching with JSP and HTML5: how to disable caching server-side

此生再无相见时 提交于 2021-02-20 04:49:42
问题 I've a Jsp that returns this html 5: <html> <head> <title>Application</title> <!-- Some script includes here --> </head> <body> <!-- My html here --> </body> </html> At the moment the user need to disable caching into the browser, else the old page is reloaded every time. I tried to force no-caching with a scriptlet in that way, but without success: <% response.addHeader("Cache-Control","no-cache"); response.addHeader("Expires","-1"); response.addHeader("Pragma","no-cache"); %> Asde the fact

Caching with JSP and HTML5: how to disable caching server-side

那年仲夏 提交于 2021-02-20 04:49:07
问题 I've a Jsp that returns this html 5: <html> <head> <title>Application</title> <!-- Some script includes here --> </head> <body> <!-- My html here --> </body> </html> At the moment the user need to disable caching into the browser, else the old page is reloaded every time. I tried to force no-caching with a scriptlet in that way, but without success: <% response.addHeader("Cache-Control","no-cache"); response.addHeader("Expires","-1"); response.addHeader("Pragma","no-cache"); %> Asde the fact

Add multiple tags to marker

不羁岁月 提交于 2021-02-20 04:47:17
问题 Created i model like in answer. Also added tags in markers: MarkerTag tag = new MarkerTag(); Marker marker = map.addMarker(new MarkerOptions() .position(new LatLng(47.045029, 28.861427)) .title("Marker") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)) .snippet("Population: 4,137,400")); tag.setEmail("first@gmail.com"); tag.setPhoneNumber("+37369490007"); marker.setTag(tag); Marker marker2 = map.addMarker(new MarkerOptions() .position(new LatLng(47.000327, 28

How to upload to Imgur (API v3) using binary format of image?

前提是你 提交于 2021-02-20 04:43:56
问题 As per the API we can upload images as a binary file. https://api.imgur.com/endpoints/image#image-upload I tried the following to read the file into a byte array. // Example 1 byte[] fileBytes = new byte[(int) new File("/home/sample.png").length()]; fileBytes = FileUtils.readFileToByteArray( this.imageRequest.getFile() ); String sImageBinaryData = new String( fileBytes ); How exactly should i extract binary data of an image? PS: I am not interested to know how to upload image using (base64 &

How to upload to Imgur (API v3) using binary format of image?

China☆狼群 提交于 2021-02-20 04:42:21
问题 As per the API we can upload images as a binary file. https://api.imgur.com/endpoints/image#image-upload I tried the following to read the file into a byte array. // Example 1 byte[] fileBytes = new byte[(int) new File("/home/sample.png").length()]; fileBytes = FileUtils.readFileToByteArray( this.imageRequest.getFile() ); String sImageBinaryData = new String( fileBytes ); How exactly should i extract binary data of an image? PS: I am not interested to know how to upload image using (base64 &

Authenticate API Requests in Spring using Firebase Auth

梦想与她 提交于 2021-02-20 04:37:52
问题 Im already authenticating access to my API using a Firebase Auth token (JWT) which is passed inside the Http Authorization Header as Bearer token. This works fine using auto configuration. Now I want to map from the authentication to a user record in my DB. How do I need to adapt the security filter chain? This configuration is automatically applied by spring boot according to the docs and can be overridden: @Override protected void configure(HttpSecurity http) throws Exception { http

Rest | @Produces and @Consumes : why dont they both get called for same MIME-type

依然范特西╮ 提交于 2021-02-20 04:30:07
问题 a newbie in JAX-REST (jersey 1.8 impl) I have a class for Resource "/hello" package com.lbs.rest; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("/hello") public class Test { //-- produces MIME type text/plain @GET @Produces(MediaType.TEXT_PLAIN) public String thankYouTxt(){ System.out.println("thankYouTxt"); return "thankYouTxt\n"; } //-- consumes MIME type text/plain @GET @Consumes(MediaType