Logging Best Practices using Log4j

Log4j is a logging library for Java applications and the purpose of inserting log statements into the code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications.

Callable and Future in Java

Here I am going to give you an example on Callable and Future in Java. public interface Callable<V> A task that returns a result and may throw an exception. Implementors define a single method with no arguments called call. The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another…

Log4j Configurations – Controlling Logging to Multiple Files

Introduction The purpose of inserting log statements into the code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications. Features of Log4j We can enable logging at runtime without modifying the application binary. We can control the behavior of…

Sanitize JSON using Java

Introduction Here I am going to tell you how to sanitize JSON (JavaScript Object Notation) string using Java program. Given JSON-like content, convert it to valid JSON. The OWASP JSON Sanitizer Project is a simple to use Java library that can be attached at either end of a data-pipeline to help satisfy Postel’s principle: be conservative in what you do,…

Extract Numeric Values from a String in Java

This tutorial will show you how we can extract the first non-breakable numeric values from a string using Java as well as all numeric values from the string. I am going to use regular expression for extracting the numeric values from string. I am going to use d and w for representing digits and characters in the string. This example…

LRU Cache Implementation In Java

Introduction A cache is an amount of faster memory used to improve data access by storing portions of a data set the whole of which is slower to access. Sometimes the total data set are not actually stored at all; instead, each data item is calculated as necessary, in which case the cache stores results from the calculations. If your…

Remove Values From A Row Or Remove A Row From Excel File Using Apache POI In Java

Introduction In this tutorial I am going to show you how to remove value from a row or remove a row completely from the excel file using apache poi library. The Apache POI is used with Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft’s OLE 2 Compound Document format (OLE2). You…

Font in excel file using Apache POI in Java

I am going to show you here how to work with font in excel file. With this example I will show you how to create different fonts for text and put it in an excel file using Apache POI in Java language. The Apache POI is to create and maintain Java APIs for manipulating various file formats based upon the…

Border and Color in excel file using Apache POI in Java

Introduction In this example I will show you how to create border around a cell and put color on a particular cell like background color, foreground color using Apache POI in Java language. The Apache POI is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft’s OLE 2…

Text Alignment In Excel File Using Apache POI In Java

I this example I will show you how to align text in an excel file using Apache POI in Java language. The text can be aligned left, right, center, justify using apache poi library. The Apache POI is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft’s OLE…