Grails Cookbook - A collection of tutorials and examples

Left Pad String in Java

In this post, we will discuss the Java Left Pad String. If you want to attain a specific target length, you will have to learn and understand the written example codes below in order to pad a custom character to the left side of a String.

Java Substring

One of the necessary inclusion of your tool in controlling String is the substring method. Java Substring is a valuable method in Core Java Programming. It's job is to remove or take out a sequence of characters from a String and swaps it with a new String value. By the end of this post, you will be able to understand how Java Substring works.

Left Pad String With Spaces in Java

When you work on a program or create a system that requires you to pad a String using spaces, all you need to do is to consider the width of a String. If the width is less than the target length, you can pad the String with spaces to guarantee the length of that String. Java left pad string with spaces is important specially when interfacing with older systems like a mainframe, where deciding which part of data is defined by number of characters, instead of more sophisticated way like XML or JSON format.

Convert Java Integer To Fixed Length String

There are situations where you want to convert a Java Integer to Fixed Length String. This is typical when we want to align Strings for visual effects, or some formatting required by the next system that will consume the output. We will show how to convert numbers to fixed length String in this post.

Java Split String Into ArrayList

There is a method that splits a String into an array of substrings given a specific delimiter, and this is the Java split() method. Converting a Java String into ArrayList using this method is essential and can be useful in many cases. Let's observe and study the given examples below for a deeper understanding.

Split String Into Array Of Integers in Java

Remember that the String.split() method splits a String into an array of substrings given a specific delimter. Each susbtring represents a number, which can be converted into an array of integer.

Java String Split Count

Just a reminder that the Java String.split() method is used to split a String to make an array of substrings through a specific delimeter. This topic will discuss on how the system will count the substrings created from the split method. Study and observe the written examples below:

Java String Split Newline

There are cases in which new line is used as a delimiter to split a java string. An example would be, when it is used to load the contents of a text document to a String if you want to break it line by ...

Double To String With 2 Decimal Places In Java

We will now discuss how to convert Java Double To String using 2 Decimal Places, and what are the methods and parameters that can help you acquire it. Although with that knowledge, an integer becomes an number if there's a separator that can describe what's it for. For example, 1234 is 12.34 if we put a dollar sign and separate it with a decimal point. Another example is when we put a comma separator to make it $1,234.00. In this topic, we will explore the details and process of converting a double to string with 2 decimal places. Check out the written examples below.

Double To String Without Exponential Scientific Notation in Java

What we will discuss in this topic is another data type which is called double. A good advantage from this data type is its conveniency and precision when it comes to dealing with numbers that are not whole. Although sometimes, when we try to convert a Double variable to a String, we get answers that are in exponential or scientific notation form. Check out below some examples of the process of converting Java double to string without exponential scientific notation in the Java Programming Language.