Posts Tagged ‘Java’

Java 8 Lambda Expressions Tutorial with Examples

Java 8 Lambda Expressions Tutorial with Examples
Java is a first-class object-oriented language. With the exception of primitive data types, everything in Java is an object. Even an array is an Object. Every class creates instances that are objects. There is no way of defining just a function / method which stays in Java all by itself. There is no way of passing a method as argument or returning a method body ...
Tags: ,

Java 8 Default Methods Tutorial

Java 8 Default Methods Tutorial
Java 8 Default Method tutorial. Overview of Virtual extension method in Java 8. How to define default methods to interfaces in Java 8.
Tags: ,

Java Locale List

Java Locale List
Here is a complete list of Locales in Java. This list is compiled using the mighty java.text.SimpleDateFormat class.The class SimpleDateFormat provides a method getAvailableLocales() which gives array of java.util.Locale objects. This is java locale list. We can iterate over this list and get all relevant information about these locales.By the way, the above tag cloud ...
Tags:

HTML5 Server-Sent Events with Java Servlets example

HTML5 Server-Sent Events with Java Servlets example
Since the dawn of modern web applications, push notifications have gained significant traction in industry. Instead of pooling data from server it has now become common that server should notify client.Ajax is so pervasive these days it is almost seen on every web page we visit. This is all good if you want to refresh a ...

Oracle Java JDBC: Get Primary Key of Inserted record

Here is a small write-up which should help those who still write plain Java JDBC code. I know we have some wonderful persistence frameworks like Hibernate that make ones life comfortable but the reality is we still have to deal with plain old JDBC apis. If you are poor chap like me, below code should make your ...
Tags: ,

Dynamic Property Loader using Java Dynamic Proxy pattern

While reading through Stackoverflow, I came up to this interesting question: Java Properties File binding to Java Interface. The idea is simple but quite helpful.Basically we create an interface like:interface LoginConstants extends Constants { @DefaultStringValue("Welcome to my super app") @Key("appDescription") String appDescription();@DefaultStringValue("Ok") @Key("okButtonLabel") String okButtonLabel(); }And whenever we want to use ...

How to Redirect Standard Output/Error in Java

System.out and System.err stream objects are mapped to "standard" output and error stream respectively. By default, Java display standard output/error on display console.Thus, when we print a statement using System.out:System.out.println("Hello World!"); System.err.println("errr.. Hello World!");It prints the messages to default console.What if you want to reassign the "standard" output and error stream? Lets say you want to redirect all those standard out messages in a ...

Read / Write Excel file in Java using Apache POI

Read / Write Excel file in Java using Apache POI
Apache POI is a powerful Java library to work with different Microsoft Office file formats such as Excel, Power point, Visio, MS Word etc. The name POI was originally an acronym for Poor Obfuscation Implementation, referring humorously to the fact that the file formats seemed to be deliberately obfuscated, but poorly, since they were successfully reverse-engineered.In this tutorial we will use Apache POI library ...

How to update JSTL Locale dynamically

How to update JSTL Locale dynamically
When you use JSTL format tag <fmt:formatDate> and <fmt:formatNumber>, JSTL automatically takes care of locale resolution. Depending on the browser's locale setting JSTL will display the date and numbers.You may want to override this default behavior. For example in case where you want to display date format only in en_US locale irrespective of user locale setting of browser. Or you may want to store user ...
Tags: , ,

Eclipse: Ignore “not declare static final serialVersionUID” warning

Eclipse: Ignore
Whenever you write a Java class in Eclipse which implements java.io.Serializable interface, you'll get this warning:The serializable class XXXX does not declare a static final serialVersionUID field of type longWhy do we need serialVersionUID? Whenever we implement java.io.Serializable interface, we explicitly tell JVM that this class can be serialized. Meaning, we might convert object of this ...
Page 1 of 812345...Last »