java-api

Why is the java.util.Scanner class declared 'final'?

99封情书 提交于 2019-12-05 11:20:33
I use the Scanner class for reading multiple similar files. I would like to extend it to make sure they all use the same delimiter and I can also add methods like skipUntilYouFind(String thisHere) that all valid for them all. I can make a utility-class that contain them, or embed the Scanner Class as a variable inside another class but this is more cumbersome. I have found some reasons to declare a class final, but why is it done here? Probably because extending it and overwriting some of it's methods would probably break it. And making it easier to overwrite methods would expose to much of

Any Cloud Print API For ANDROID

江枫思渺然 提交于 2019-12-04 17:55:41
Does anyone know if there is a Cloud print API for Android? .To develop our own Cloud print Apk for Android device. Any tutorial or Sample code for this will be helpful There is an Google Cloud Print API available which I wrote a while back: http://cloudx.fun2code.de/en/api.html JavaDoc and examples are also available. For a more detailed example have a look at the blog entry: http://fun2code-blog.blogspot.de/2011/10/setting-up-cloud-print-printer-using.html Hope that helps... Check this for Google Cloud Print integration with Android. https://developers.google.com/cloud-print/docs/android

Why doesn't Java 8's ToIntFunction<T> extend Function<T, Integer>

白昼怎懂夜的黑 提交于 2019-12-04 03:22:52
问题 If I wrote the ToIntFunction interface, i'd want to encode in the interface the fact that it's just a function that returns a primitive int, like this: @FunctionalInterface public interface ToIntFunction<T> extends Function<T, Integer> { int applyAsInt(T value); @Override default Integer apply(T value) { return Integer.valueOf(applyAsInt(value)); } } I was wondering, is there a compelling reason Java 8 API designers chose to keep the primitive alternatives completely separate from Function?

Elastic Search Parent-Child Data Search Java API

萝らか妹 提交于 2019-12-03 17:32:08
I am new to ELastic Search. Data in Elastic search is in Parent-Child Model.I want to perform search in this data using java api. parent type contains author details and child type contains book details like book name,book publisher, book category. While performing a search on child details,I need to get the parent details also and vice versa. Sometimes search conditions will be on parent type as well as child. eg search for books written by author1 and type Fiction . How can i implement this in java? I have referred the elastic search documentation but not able to get a solution Please help

Use standard SQL queries in java bigquery API

孤街浪徒 提交于 2019-12-02 06:24:57
问题 Is it possible to use standard SQL queries when using java bigquery API? I am trying to execute query but it throws com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request "message" : "11.3 - 11.56: Unrecognized type FLOAT64" 回答1: There are two ways to use standard SQL with the BigQuery Java API. The first is to start your query text with #standardSQL , e.g.: #standardSQL SELECT ... FROM YourTable; The second is to set useLegacySql to false as part of the

How to covert this elastic search functional score query to java API

一笑奈何 提交于 2019-12-02 01:30:46
How to convert the below ES query to Java API? I am using elastic search 2.3.3 GET /schema_name/_search { "from": 0, "size": 200, "query": { "function_score": { "query": { "match_all": {} }, "boost": "5", "functions": [{ "filter": { "term": { "alert_code": "event_rule_1" } }, "weight": 50 }, { "filter": { "term": { "alert_code": "event_rule_2" } }, "weight": 30 }, { "filter": { "term": { "alert_code": "event_rule_3" } }, "weight": 10 }, { "filter": { "term": { "alert_code": "event_rule_4" } }, "weight": 10 }, { "filter": { "term": { "alert_code": "event_rule_5" } }, "weight": 50 }, { "filter":

PDF generated with PDFBox is blank

我们两清 提交于 2019-12-02 00:23:05
I am trying to write content into a PDF file. I have written the code public ByteArrayOutputStream createPDF(String text) throws IOException, COSVisitorException { PDDocument document; PDPage page; PDFont font1; PDPageContentStream contentStream; ByteArrayOutputStream output = new ByteArrayOutputStream(); document = new PDDocument(); try { page = new PDPage(); document.addPage(page); contentStream = new PDPageContentStream(document, page); contentStream.beginText(); contentStream.moveTextPositionByAmount( 100, 700 ); contentStream.drawString("Hello World Hello World Hello World Hello World

Use standard SQL queries in java bigquery API

戏子无情 提交于 2019-12-01 23:56:46
Is it possible to use standard SQL queries when using java bigquery API? I am trying to execute query but it throws com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request "message" : "11.3 - 11.56: Unrecognized type FLOAT64" There are two ways to use standard SQL with the BigQuery Java API. The first is to start your query text with #standardSQL , e.g.: #standardSQL SELECT ... FROM YourTable; The second is to set useLegacySql to false as part of the QueryJobConfiguration object. For example (taken from the documentation ): public static void runStandardSqlQuery

Why doesn't Java 8's ToIntFunction<T> extend Function<T, Integer>

时间秒杀一切 提交于 2019-12-01 17:28:59
If I wrote the ToIntFunction interface, i'd want to encode in the interface the fact that it's just a function that returns a primitive int, like this: @FunctionalInterface public interface ToIntFunction<T> extends Function<T, Integer> { int applyAsInt(T value); @Override default Integer apply(T value) { return Integer.valueOf(applyAsInt(value)); } } I was wondering, is there a compelling reason Java 8 API designers chose to keep the primitive alternatives completely separate from Function? Is there some evidence that they considered doing so and decided against it? I guess similar question

Can I store image files in firebase using Java API?

柔情痞子 提交于 2019-11-30 10:14:25
Is there any way to store image files in firebase using Java api to be used for android application? I have read this thread Can I store image files in firebase using Java API and still there is no answer. I know that there is an official api for it, called firepano here is the link https://github.com/firebase/firepano but it is for Javascript library. is there any solution for Java library?? I used this code and now it's working: Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.chicken);//your image ByteArrayOutputStream bYtE = new ByteArrayOutputStream(); bmp.compress