How to post tweets using Twitter4j Java API

Here we will discuss on how to post tweets using Twitter4j Java API. Twitter4j is an unofficial Java library and using this you can easily integrate Java application with Twitter service. You can easily use standalone jar for this twitter4j API or using maven or gradle build tool to download the required jar on the classpath automatically.

Callback method example in Java

Here I am showing a simple example on what is callback method in Java. A callback is a piece of code that you can pass as an argument to be executed on some other code. Since Java doesn’t yet support function pointer, the callback methods are implemented as command objects. A callback will usually hold reference to some state to…

Excel Custom Filters on Number Column using Java and Apache POI

Introduction In this example I am going to show you how to work with filters in excel file on text column using Java and Apache POI library. The following list of custom filters for number columns can be implemented: Equals Does Not Equal Greater Than Greater Than Or Equal To Less Than Less Than Or Equal To Between Top 10…

Excel Custom Filters on Text Column using Java and Apache POI

Introduction In this example I am going to show you how to work with filters in excel file on text column using Java and Apache POI library. The following list of custom filters for text columns can be implemented: Equals Does Not Equal Begins With Ends With Contains Does Not Contain

Add Or Subtract Days Weeks Months Years On Java 8 Date

Java 8 Date In this tutorial I am going to show you how to add days, weeks, months, years to a particular date in Java 8 or later. Similarly I will also show how to substract days, weeks, months, years from a particular date. The date is actually LocalDate API in Java 8 or later. The one of the important…

How to create PDF File Content using Java

Introduction In this tutorial I am going to show you how to create PDF file content with different formats using Java programming language. In this tutorial I am going to use iText library to generate the PDF document. Many applications require dynamic generation of PDF documents. The applications, where dynamically generated PDF is required, are banking system generating statements for…

How To Read CSV File Using Java

Introduction In this tutorial I will show you how to read CSV file using Java 7 or later versions. I will use here Java’s new feature Path API. I will also use Java 8’s Stream API to split the comma separated line and map the record into String array. I am going to show you how to read file content…

Busy Waiting or Spinning Example in Java Multi-threading

What is busy waiting or spinning? Busy spinning or waiting in multi-threading environment is a technique in which a process repeatedly checks if a particular condition is true instead of wait() or sleep() method and without releasing the CPU. In other words busy spinning is one of the techniques to wait for events without releasing CPU. Busy waiting or spinning…

How to exchange data between two threads using Exchanger in Java

We will discuss about how to exchange data between two threads or a pair of threads. The Exchanger class under java.util.concurrent package was introduced in JDK 1.5 along with CyclicBarrier, CountDownLatch to exchange data between two threads only. A synchronization point at which two threads can pair and exchange data within pair using the exchange() method of the Exchanger class….

How Fork Join works in Java

Introduction Here I am going to tell you how fork join works in Java and how to use fork join in Java. Fork join was introduced in java version 1.7. JDK 7 and Java version 7 introduced many good features, such as, string in switch case, multi-catch block, automatic resource management, etc. and fork join was one of them. Fork…