Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

 

and many more ....

 

 

List files with regular expression filtering

This is an example of how to list files using regular expression filtering. In order to list Files using regular expressions to filter them we have set the example below: Class DirFilter implements the FilenameFilter. It has a Pattern that is initialized by compiling a String regular expression to a Pattern, using compile(String regex) API method of Pattern. It also has a ...

Read More »

Remove line termination characters from string

In this example we shall show you how to remove line termination characters from a String, using regular expressions. To remove line termination characters from a String one should perform the following steps: Create a String that contains a line separator as specified by the System.getProperty(String key) API method. Compile a String regular expression to a Pattern, using compile(String regex) ...

Read More »

Compile Reg Ex pattern with multiple flags

With this example we shall show you how to compile regular expression to a Pattern with multiple flags. Compiling a regular expression to a Pattern with multiple flags implies that you should: Compile a String regular expression to a Pattern, using compile(String regex) API method of Pattern. Use matcher(CharSequence input) API method of Pattern to create a Matcher that will match ...

Read More »

Greedy and non-greedy Reg Ex matching

This is an example of how to use greedy and non-greedy regular expression matching. Greedy matching means that the expression will match as large a group as possible, while non-greedy means it will match the smallest group possible. Matching with greedy and non-greedy regular expressions implies that you should: Compile a String regular expression to a Pattern, using compile(String regex) API ...

Read More »

Check if a string matches a Pattern

In this example we shall show you how to check if a String matches a Pattern. To check if a String matches a Pattern one should perform the following steps: Compile a String regular expression to a Pattern, using compile(String regex) API method of Pattern. Use matcher(CharSequence input) API method of Pattern to create a Matcher that will match the given ...

Read More »

Get package name

This is an example of how to get the package name of a class. Getting the package name of a class implies that you should: Create a new object of the class. Use getClass() API method of Object for the class to get the runtime class of this object. The returned Class object is the object that is locked by static ...

Read More »

Get super class of an object

With this example we shall show you how to get the super class of an object. To get the super class of an object implies that you should: Create a new Object. In the example we first create a new String object and then we create a new List object. Get the super class of the object, using getClass() API ...

Read More »

Get class from an object

In this example we shall show you how to get the class of an Object. To get the class that represents an Object one should perform the following steps: Create a new Object. Get the class of the Object, using getClass() API method of Object. It returns the runtime class of this Object. The returned Class object is the object that ...

Read More »

Get methods return type

This is an example of how to get the return type of a classe’s methods. To get the return type of a classe’s methods one should perform the following steps: Get the array of Method objects reflecting all the methods declared by the class, using getDeclaredMethods() API method of Class. This includes public, protected, default (package) access, and private methods, but ...

Read More »

Get Modifiers from an Object

In this example we shall show you how to get the modifiers of a class. To get the modifiers of a class one should perform the following steps: Call getModifiers() API method of Class to get the Java language modifiers for this class or interface, encoded in an integer. The modifiers consist of the Java Virtual Machine’s constants for public, protected, private, ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns