Browsed by
Category: Java

Flowable Notes for Beginners

Flowable Notes for Beginners

Flowable Notes for Beginners 1. Flowable is a set of process and tasks inside it. Example snippet (as per bpmn20.xml): Below snippet is only for understanding on how the process and tasks will be created in flowable for any bpmn process. Explanation: couponupload is process id/key created to upload the coupons for a particular shop. This process will have set of tasks in order to complete the whole process, here totally 2 process, one is store already partnered or not…

Read More Read More

52 total views, no views today

Developers Repeated Mistakes

Developers Repeated Mistakes

In this post we are going to discuss about the repeated mistakes of developers during design/implementation/planning etc. This is just a sudden thought process, so this post will grow on my day to day experience and research wise only. Feel free to comment your repeated mistakes to add it to this master list. In Hibernate/Databases: While creating/planning a column for description, we forget to define the length of values it can hold or even forget to think such scenarios. So…

Read More Read More

102 total views, no views today

okhttpclient get/post/form requests example:

okhttpclient get/post/form requests example:

okhttpclient get/post/form requests example: Maven dependency: <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>3.11.0</version> </dependency> okhttpclient with formbody example: public class App { public static void main( String[] args ) throws IOException { OkHttpClient client = new OkHttpClient(); RequestBody formBody = new FormBody.Builder() .add(“client_id”, “some_value”) .add(“client_secret”, “some_value”) .build(); Request request = new Request.Builder() .url(“some_url”) .post(formBody) .addHeader(“authorization”, “headers_here”) .addHeader(“cache-control”, “no-cache”) .build(); Response response = client.newCall(request).execute(); System.out.println(“response => “+response); } }   okhttpclient with multipart form data request example: public class App { public static void…

Read More Read More

206 total views, no views today

Trim() not working with excel read apache poi in Java:

Trim() not working with excel read apache poi in Java:

Trim() not working with excel read apache poi in Java: While reading from the excel, you need to make sure you are considering this unicode value as well \u00A0 along with white spaces to handle all the possible inputs. Trim() does not help us for this, and below are the tries I made and got the solution, posted all here to help you with n number of possible use cases and solutions. Not working: Try 1: row.getCell(0).getStringCellValue().replaceAll(“\u00A0”, “”);   Try 2:…

Read More Read More

248 total views, no views today

[Solved] The entity “le” was referenced, but not declared.’ itext pdf

[Solved] The entity “le” was referenced, but not declared.’ itext pdf

[Solved] The entity “le” was referenced, but not declared.’ Issue: If you used &le; then you will get this issue. Solution: You have to actually use &lt;=, currently it does not support &le; this can be done as &lt;= Hope this helps! 234 total views, no views today

234 total views, no views today

How to create a text/html file from java string ?

How to create a text/html file from java string ?

How to create a text/html file from java string ? try { File file = new File(“ngd.txt”); // ngd.html for html file generation. FileWriter fileWriter = new FileWriter(file); fileWriter.write(html); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } 224 total views, no views today

224 total views, no views today

Arraylist to Array Using ToArray() in java

Arraylist to Array Using ToArray() in java

Syntax: <T> T[] toArray(T[] a) Eg : String[] y = x.toArray(new String[0]); T – the runtime type of the array to contain the collection Parameters: a – the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. Returns: an array containing the elements of this list Throws: ArrayStoreException – if the runtime type of the specified array is not a…

Read More Read More

706 total views, no views today

hashMap Vs TreeMap Vs LinkedHashMap

hashMap Vs TreeMap Vs LinkedHashMap

════════════╦═════════════════════╦═══════════════════╦═════════════════════╗ ║ Property ║ HashMap ║ TreeMap ║ LinkedHashMap ║ ╠══════════════╬═════════════════════╬═══════════════════╬═════════════════════╣ ║ Iteration ║ no guarantee order ║ sorted according ║ ║ ║ Order ║ will remain constant║ to the natural ║ insertion-order ║ ║ ║ over time ║ ordering ║ ║ ╠══════════════╬═════════════════════╬═══════════════════╬═════════════════════╣ ║ Get/put ║ ║ ║ ║ ║ remove ║ O(1) ║ O(log(n)) ║ O(1) ║ ║ containsKey ║ ║ ║ ║ ╠══════════════╬═════════════════════╬═══════════════════╬═════════════════════╣ ║ ║ ║ NavigableMap ║ ║ ║ Interfaces ║ Map ║ Map ║ Map ║…

Read More Read More

696 total views, no views today

Why StringBuffer/StringBuilder should be avoided in HashMap?

Why StringBuffer/StringBuilder should be avoided in HashMap?

Why StringBuffer/StringBuilder should be avoided in HashMap?   This is one of the core java interview question under collections category. Generally in all the map manipulations we use string and avoid stringbuffer and stringbuilders, because both are mutable. What is the issue if is mutable ? If you are keeping your hashmap’s key/value as stringbuilder/stringbuffer then once after you inserted the value in the map, if any of the key/value modified then it actually affects inside the map as well,…

Read More Read More

383 total views, no views today

Generate angular + Java code using yeoman & Jhipster

Generate angular + Java code using yeoman & Jhipster

Generate angular + Java code using yeoman & Jhipster Ensure you have installed yeoman (yo when dealing with npm and yarn) and jhipster (generator-jhipster when dealing with npm and yarn). If not installed, have a quick look at,     Step 1: Run yo jhipster     It will ask around 10 to 15 questions, you can provide the sample values as per the above screenshot and proceed to step 2:   Step 2: Angular 5 & Java Codes are…

Read More Read More

628 total views, no views today