Java BufferedReader Example

java-thumbnail

In our previous example I have explained about the FileReader. FileReader is useful for reading the text content by characters. This is slow in performance when using for the huge files. BufferedReader is buffering the text for Reader’s. Buffering will speed up the IO operation. Instead of reading one character at a time using the […]

Java FileReader Example

java-thumbnail

Java has several File IO classes for reading and writing into the files. Each class has its own advantages. This example illustrates how to use FileReader for reading a text file. The main purpose of using the FileReader is to read the text content from a file where FileInputStream is used for reading the stream of […]

WeakReference in Java

java-thumbnail

WeakReference, SoftReference and PhantomReference are added to the Java API long back but have not effectively used by most of the programmers. The reason being the less knowledge on the concept of how these APIs work for managing the references. Basically these APIs are helping the Garbage Collector to claim the memory looking at the […]

How Much Faster Is Java 8?

java-thumbnail

Java SE 8 was released last month (March 18, 2014). Traditionally, every new major JRE version comes with a free performance boost. Do we get another free lunch? And how big is the gain this time? Let’s benchmark it. Benchmark methodology Run the same code with 3 different JRE versions (SunJDK 1.6.0_26, OpenJDK 1.7.0_51 and OpenJDK 1.8.0). The code […]

How To Get Bean Property Details In Java

java-thumbnail

Java API jabs java.bean package for working with the Java beans and its properties. In our previous example I have explained how to write bean PropertyChangeListener. This example is just an extension to that post and it provides the sample for getting the property method details. Lets look at the example. BeanPropertyDetails.java Bean.java Output…

How to Write Bean PropertyChangeListener in Java

java-thumbnail

Property change events occur when ever there is change in the property values. We assume that the component conforms with the Java Bean specification. JavaBean s property is accessed using the set or get methods. These methods are invoked by the application for setting or getting the values from the bean. This doesn’t have any […]

How To Split String In Java

java-thumbnail

If you want to split the String value into the different parts based on the delimiter or regular expression, String class provides split() which does the job. It has two overloaded methods with the following syntax: split(String regex) – Splits this string around matches of the given regular expression. split(String regex, int limit) – Splits […]

Java String IndexOf Example

java-thumbnail

Java String class consist of methods for finding the index of occurrence in the given string literals. If there is no occurrence of the given characters, then it will return the “-1″.  The following are the few methods which is very useful to find the string values. indexOf(char) – Returns the index of the character […]

Java 8 StringJoiner Example

java-thumbnail

Java 8 introduces a new String manipulation API StringJoiner. Using StringJoiner, one can append multiple string values with the pre-defined format like commas, prefix and suffix. This syntax is very similar to the one used with the another framework Guava. StringJoiner Constructors This class takes two constructors: StringJoiner (delimiter) – Adds only the delimiter between the […]

Java String Reverse using Recursion

java-thumbnail

This example shows how to reverse a string using the recursion technique. There are several ways to reverse a string one I have explained using the StringBuffer. Note: The best way is not to choose recursion technique for reversing the string. These concepts are usually used to teach students the recursion , not actual best practices […]

Close
Please support the site
By clicking any of these buttons you help our site to get better