how to create generic parametric arrays

Considering this following class public class Pair <T, U> { public T first ; public U second ; public Pair (T first , U second ) { this . first = first ; this . second = second ; } } Write the method public static <T, U&...
more »

2017-10-04 23:10 (0) Answers

Where to store encryption passwords

I get the reasons for security and encryption. But I'm really confused on how to set it up or use it. I'm working on encrypting passwords our application uses to access the database and other third-party APIs. I'm working under the assumption that p...
more »

2017-10-04 22:10 (0) Answers

connect my spring boot project to a mysql database

I am trying to connect my spring boot project to mysql database but i keep encountering an error but cant seem to work out what it is. spring.jpa.hibernate.ddl-auto=create spring.datasource.url=jdbc:mysql://localhost:3306/mydb?useSSL=false spring.da...
more »

2017-10-04 17:10 (2) Answers

Create stream lazily

How can a stream be created lazily? During migration of collection based code I have run into this pattern multiple times: Collection collection = veryExpensiveCollectionCreation(); return Stream.concat(firstStream, collection.stream()); The resul...
more »

2017-10-04 16:10 (1) Answers

Firestore getProductID cannot be null error

I am trying to use the new Firestore released by Firebase in my android app. Unfortunately I keep getting this error when trying to write to the database. public class MainActivity extends AppCompatActivity { EditText txtName,txtSurname; @Override...
more »

2017-10-04 14:10 (3) Answers

Reading Oracle htp.p output into Java app

We have built a dynamic stored proc reader due to the nature of our system. The only issue I have left is I am unable to read the htp.p output back into my application after calling the proc. Due to the reader building the proc dynamical from a requ...
more »

2017-10-04 11:10 (0) Answers

How to add plugin to init.gradle?

I need to add mirror repositories to Gradle. For that I use gradle-maven-plugin Is it way to add this plugin to init.gradle? I tried to add like this: buildscript{ repositories { maven { url "https://plugins.gradle.org/m2/...
more »

2017-10-04 11:10 (0) Answers

Time difference calculation error

I have to calculate total fly time minutes between departure airport and arrival airport. This job is done by this code snippet: public int calculateFlightDuration(String departureDateTime, String depAirportCode, String arrivalDateTime, ...
more »

2017-10-04 09:10 (1) Answers

Cache control not getting set via servelet

I tried to set cache control headers to response via Java filter ,but it seems they are not getting added in repose. Instead of the headers I have set via code I can see another header ** Cache-Control: max-age=15552000 **. I use the below code in f...
more »

2017-10-04 09:10 (0) Answers

byte[] as an input for a rest web service

having problems with the following. i can't seems to pass in the byte[] created from a file into a web service. when i execute my client code, the server log throwing nullpointer for the pdfFile byte[]. please assists here. Server side: @RequestMap...
more »

2017-10-04 07:10 (1) Answers

Generating Gradle-like Test Reports from Maven

I've worked with multiple Gradle projects that generate reports in the format pictured below. I like this format: it presents the information I require in a concise and intuitive format. Question: Is it possible to generate reports in an identical f...
more »

2017-10-04 07:10 (1) Answers

Integer type not working as expected (Java)

I'm writing one of my first programs dealing with generics and standard OOP principles in Java, however I am running into a bit of a problem when dealing with the Integer type. I noticed that Integers are expected to have a method named compareTo(In...
more »

2017-10-04 06:10 (1) Answers

How to password protect a string of text?

I've seen lots of similar questions but not quite sure which is applicable to this situation. I have a program that sends sensitive information by email. I would like the email to be scrambled such that the recipient must know the password in order t...
more »

2017-10-04 06:10 (2) Answers

Gzip decompression adding one extra byte ... Why?

I've written a simple Java code snippet which takes a String, converts it to byte[], and then compresses it using Gzip. Then it decompresses the result to get back the byte[], which now contains one extra garbage value byte. Why is there a garbage va...
more »

2017-10-04 03:10 (1) Answers

Passing around generic classes in Dataflow

I'm using the Apache Beam version of Dataflow, and am currently running into an issue when I try to create a PTransform that outputs a generic class. Here's a minimal example of such a transform, which simply outputs a type repeatedly. public class ...
more »

2017-10-04 01:10 (1) Answers

Spring Boot cache with ContentVersionStrategy

I'm using Spring Boot in a web project, and I wanted to use the static content cache feature. Using the ContentVersionStrategy with the following configuration in application.properties spring.resources.chain.enabled=true spring.resources.chain.cac...
more »

2017-10-03 23:10 (0) Answers