How to Convert a Map to Set in Java

In this post, we will learn as how to Convert a Map to Set in Java.We will see how to do this using JDK.   1. Conventional Method To convert, Java Map to Set, we can use the conventional constructor with HashSet, however, there are few things to consider before we proceed with the conversion.  … Read more

How to Join Multiple Lists in Java

In this short post, we will learn how to join multiple lists in Java. We will be covering how to do this in Java 8, Java 7 and how we can use Apache Common API to join these lists.   1.  Join Multiple Lists in Java Java 8 Stream API provides a couple of different options … Read more

JVM Parameters

Introduction to JVM Parameters In this post, we will be covering some of the most important and critical JVM Parameters which can be used to configure and fine tune JVM. Performace of the JVM depends on the factor as to how well JVM is configured for a given application. Let’s cover few of the well known JVM … Read more

Split a String in Java

Split a String in Java In this small post, we will explore how to split a string in Java.   Introduction Splitting a String in Java is a common operation, we will discuss different method available in Java to split a String.   1. String#split() Method Java String class provides a convenient and easy split() … Read more

Java NIO2 File Attributes

Introduction to Java NIO2 File Attributes API In this post, we will cover Java NIo2 File Attributes. File attributes are also known as metadata. Metadata can be used to find out information about the file systems like if it’s a regular file or a directory, who is the owner of the file or directory. I have already … Read more

Java Base64 Encoding and Decoding

Java Base64 Encoding and Decoding In this post, we will explore various options of Java Base64 Encoding and Decoding. We will cover mainly new Base64 API introduced in Java 8.   Introduction Base64 encoding was missing from standard JDK before Java 8. Java 8 introduced a simple yet powerful API under java.util package or specifically … Read more

StackWalker API In Java 9

Introduction to StackWalker API In Java 9 In this post, we will be covering  StackWalker API in Java 9. Stack Walking API is yet another features being introduced in Java 9   Introduction To put Stack Walk API  in Java 9 in simple words, It provides capabilities to walk through the stack in Java. StackWalker provides a … Read more

Java NIO2 WatchService

Java NIO2 – Watching a directory for changes Java NIO2 WatchService was introduced in Java 7 as part of the NIO2. WacthService provides the ability for monitoring a file or directory for change. In this articles, we will explore this exciting yet less known feature introduced under Java 7 NIO.     1. Introduction  WatchService … Read more

Java Garbage Collector

Introduction to  Java Garbage Collector In this post, we will explore what is Java Garbage Collector, How Java Garbage Collector Work? We will also cover what are the different Garbage collector available in Java and what are the new enhancement/improvement available in Java 8. This post covers basic of the Java Garbage Collector API , provide a … Read more

Java NIO Selector

Java NIO Selector In this post, we will explore feature and the basic understanding of Java NIO Selector API. The selector is an NIO component with an ability to monitor or examine multiple channels and determines which is ready for the IO operation (read or write). One of the benefits of this is to use single … Read more

Java Directory Size

Java Directory Size In this post, we will learn how to get the Java directory size or size of a folder in Java using Java 7, Java 8 and Apache Commons API.   1.  Get Size Using Java 7 We will be using Files.walkFileTree() method to recursively transverse through the files/directory to calculate the size. public … Read more

Java 9 REPL

Introduction to Java 9 REPL In this post, we will explore Java 9 REPL (Read-Evaluate-Print-Loop) feature or shortly called as JShell. Many modern languages provide a tool (Mostly called as REPL or scripting tool) for real-time statement interpretation. One benefit of such a tool is that you can easily test your code without creating a complete … Read more

Zipping and Unzipping in Java

Zipping and Unzipping in Java In this post, we will learn Zipping and Unzipping in Java using API. We will also discuss some third-party API to perform these tasks.  1.  Zip a File We will be performing a simple operation to zip a single file into an archive. public class ZipSingleFile { public static void main(String[] … Read more

Collection Factory Methods in Java 9

Collection Factory Methods in Java 9 In this post, we will explore Collection Factory Methods in Java 9. Java 9 introduced a new Convenience Factory Methods for Collections.   Introduction Creating a new unmodifiable list in Java (before Java 9) is not very clean. Creating a small immutable collection in Java involves following steps Create collection. … Read more

Java nio2

Introduction to Java NIO2 This post is aiming to provide a high-level overview of the Java NIO2 API features. Java7 introduced a rich set of features to operators on the Files using Java NIO2 package. In this post, we will learn about some of the basic features introduced by Java Nio2. The java.nio.file package provides a comprehensive support … Read more

Java NIO Path

Java7 Introduced NIO2 as an enhancement to the current File API. Java NIO Path and especially Path class was one of the main entry points for NIO2 API. Path class is a representation of the underlying platform file system.Path class will create a path based on the platform you are working on. (e.g. For Linux … Read more

How to Move a File in Java

In this post, we will learn how to move a file in Java using Java7 NIO or Apache Commons IO. As part of the core java tutorials, we will cover following options. Move a file or directory using NIO and JDK 7. Move files or directory using Apache Commons IO.   1. Using JDK7 NIO Package … Read more