Home » Core Java

Core Java

Java Nio FileChannel Example

The FileChannel is a Java Nio Channel implementation for working with a file. It facilitates reading, writing, mapping and manipulating a file. The examples in this tutorial will be demonstrated via test cases with no explicit Charset specified when encoding and decoding text from ByteBuffers. 1. Introduction The FileChannel has a rich hierarchy of interfaces extending to it a diverse set of behaviors ...

Read More »

Xpath Unique/Distinct Value Example

In this article we will learn how to select a distinct value from an XML using XPath. We will use IntelliJ ans an IDE and will use Saxon API for XPATH evaluation. 1. Introduction XPath is a W3C recommendation and is a major element in the XSLT standard. It can be used to navigate through elements and attributes in an ...

Read More »

JUnit Temporary Folder Example

In this tutorial, we shall show users the usage of JUnit Temporary Folder. JUnit Temporary Folder Example is a simple example showing how we can use and why we should use this feature of the JUnit. Basic tutorials about JUnit can be found here. 1. Introduction There are some scenarios where we want to create a temporary folder and then ...

Read More »

Java 9 Functional Programming Tutorial

Hello, in this tutorial we will learn about the introduction to Functional Programming in Java 9. The idea behind this approach was to combine Haskell programming language in Java. Table Of Contents 1. Java 9 Functional Programming 1.1 All variables are final 1.2 Don’t use global variables (and forget about side effects) 1.3 Use functions as parameters 1.4 Lambda Expressions ...

Read More »

Java Nio Iterate Over Files in Directory

This example will demonstrate iterating over the files and directories recursively from a root directory. The example program will utilize some of the Java NIO features. Central to this example are the DirectoryStream, Filter, Path and Paths classes. 1. Introduction Before diving into the example program an understanding of the 4 abstractions listed above: 1.1 DirectoryStream The DirectoryStream interface enables us to ...

Read More »

Java 9 Immutable Collections Example

Hello, in this tutorial we will see another JDK 9 feature i.e. creating immutable collections in Java. Java 9 brings the long awaited approach for creating small unmodifiable Collection instances using a concise one line code. As per JEP 269, new convenience factory methods will be included in JDK 9. 1. Introduction Before Java 9, it was possible to create ...

Read More »

Java 9 Compact Strings Example

Hello, in this tutorial we will learn about the evolution of Strings in Java to Compact Strings. In any of the Java applications Strings are used extensively. I can’t remember a single application where I have not used Strings. So any optimization on String class would affect almost each and every application. 1. Introduction Since Java 9 is coming with ...

Read More »

JUnit No Runnable Methods

In this tutorial, we shall show users the usage of JUnit and explains the reason behind the No Runnable Methods error. We live in a fast age of technology where the everyday new breakthrough is going on. We have to be updated with the latest technologies around us and how they affect our lives. We have seen in our previous ...

Read More »

Java Nio HeapByteBuffer Example

This example demonstrates the usage of the Java Nio HeapByteBuffer. The Java Nio HeapByteBuffer is an odd class, one you will never reference directly and for good reason, it’s package private. Although it’s use is almost guaranteed when working with ByteBuffers unless you opt for a DirectByteBuffer (off heap). By virtue of extending ByteBuffer, it also happens to extend Buffer and implement Comparable. 1. ...

Read More »

XPath Like Operator Example

In this example we will learn about XPath like operator. We will see how we can perform a ‘like’ operation using XPath. We will make use of IDEA IntelliJ to show some examples. 1. Introduction XPath is a W3C recommendation. It stands for XML Path Language and uses “path like” syntax to identify and navigate nodes in an XML document. XPath is ...

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