How to join multiple strings using append(), StringJoiner, String.join() in Java

In this tutorial we will see the difference between StringJoiner and String.join(). These were introduced into Java 8 version. The example we create here will show how to join multiple string objects or literals or list of strings using append(), StringJoiner, String.join() API. Situation may occur when you need to join multiple string literals or objects into one. You may also find a situation when you need to convert a list of strings or a collection of strings into csv(comma separated value) strings.

Continue

Handling large data writing to Excel using SXSSF Apache POI

Introduction This tutorial will show you an example on handling large data writing to excel using sxssf Apache POI library. Having said that I will show you here how to write large data set to an Excel file using Apache POI using SXSSF. The theoretical text and concept have been borrowed from http://poi.apache.org/spreadsheet/how-to.html#sxssf SXSSF (package: org.apache.poi.xssf.streaming) is an API-compatible streaming extension of XSSF to be used when very large spreadsheets have to be produced, and heap space is limited. SXSSF achieves its low memory footprint by limiting access to the…

Continue

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 will extract all numeric values and discard all characters found in the string.

Continue

Append-String Transformer in Mule ESB

What is Mule ESB ? Mule ESB is a lightweight Java-based enterprise service bus (ESB) and integration platform that allows developers to connect applications together quickly and easily, enabling them to exchange data. Mule ESB enables easy integration of existing systems, regardless of the different technologies that the applications use, including JMS, Web Services, JDBC, HTTP, and more. This example shows how we can read a file from a source directory and append a string to the file content and display it into the console. We simply put a file…

Continue

File-To-String transformer in Mule ESB

What is Mule ESB ? Mule ESB is a lightweight Java-based enterprise service bus (ESB) and integration platform that allows developers to connect applications together quickly and easily, enabling them to exchange data. Mule ESB enables easy integration of existing systems, regardless of the different technologies that the applications use, including JMS, Web Services, JDBC, HTTP, and more. This example shows how we can read a file from a source directory and display the content into console. We simply put a file in a source directory and Mule will read…

Continue

Verify a string contains only numeric value in Java

Introduction The below example shows how to verify that a string contains only numeric value in Java. String may contain float value, double value etc. This example uses regular expression to check a string contains only numeric values. It makes sure that your string should contain only digits and dot(.). You may need sometimes to use string variable for storing numeric data. As the variable is string type, so by mistake your string variable may contain non-numeric values which are not correct values for processing further business logic. Therefore you…

Continue

String reverse example in Java

This tutorial will show you string reverse example in Java. We have various ways to reverse a string in Java and I have presented here five ways to reverse a string. String class in Java is an immutable class and that’s why it does not have reverse() method to reverse the given string. We will use here StringBuilder and StringBuffer‘s reverse() method, we will build our own custom method, using recursion with substring() method and Java 8’s Lambda and Stream API to reverse the given string.

Continue