Java ExecutorService Examples To Create Thread Pool

Java ExecutorService Examples To Create Thread Pool

Table Of Content Introduction Java ExecutorService Implementations Creating ExecutorService Creating with Executors Factory Methods Directly create an ExecutorService ExecutorService Usage execute(Runnable) submit(Runnable) submit(Callable) invokeAny() invokeAll() 1. Introduction Java ExecutorService is a framework which simplifies the creation of ThreadPool in Java and allows the execution of the task concurrently in asynchronous mode.  It accepts both Runnable and …

Read More

How to split a string in java or split by period/dot in java?

How to split a string in java or split by period/dot in java?

To splits a string in java into multiple Strings given the delimiter that separates them use java method split(regex). The returned object is an array which contains the split Strings. We can also pass a limit parameter split(regex,limit) to the number of elements in the returned array. If we pass 0 as a limit, then the method …

Read More

How to check if Key or Value exists in a Map ?

How to check if Key or Value exists in a Map ?

In this tutorial we will see how to check if Key or Value exists in a Map. Map or HashMap is the java collection class which stores data in Key-Value pair. Java collections is a set of classes and interfaces that implement commonly reusable collection data structures. To check if Key or Value exists in a Map, Map or …

Read More

How to get user home directory in java for all OS?

How to get user home directory in java for all OS?

How to get user home directory in java is the common question arises while creating Java/Swing GUI applications. You can get home directory of user using System.getProperty(“user.home”) function. Below java code shows you how to get User home directory. This code will work on Java 1.8 for all OS. Output: There is a bug#JDK-6519127 which …

Read More

Vue.js Conditional Directives Example

Vue.js Conditional Directives Example

In this tutorial we will see how to use Vue.js Conditional Directives. You can also checkout other Vue.js tutorial as listed below Other Vue.js tutorial Vue.js Hello World Example Vue.js v-bind Directive Example Most of the dynamic web application expect an ability to show or hide elements based on conditions in any front-end framework. Vue.js …

Read More

How to convert java.util.Date from java.time.LocalDate?

How to convert java.util.Date from java.time.LocalDate?

The following Java code snippet shows how to convert java.util.Date from java.time.LocalDate  and vice versa. In the first part of the code snippet we convert java.util.Date from java.time.LocalDate and back to LocalDate object. In the second part we convert java.time.LocalDate from java.util.Date and back to java.util.Date object.

Read More

Web Application with Spring Boot and Thymeleaf Example

Web Application with Spring Boot and Thymeleaf Example

In this article, I will show you a web application with Spring Boot and Thymeleaf example but first of all, let’s see what is Spring Boot and how it helps in the development of Spring Framework based web application development. Table of Content Introduction Prerequisite Download Source Code Create Spring Boot and Thymeleaf Example Web …

Read More

How to get Free, Used and Total Memory in Java ?

How to get Free, Used and Total Memory in Java ?

As you know that Java does the automatic garbage collection which you need not worry about. However sometime you want to know how large the java heap space is and how much of it is left. Information about Free, Used and Total memory in java can be used for checking your code efficiency. To obtain …

Read More

Vue.Js v-bind Directive Example

Vue.Js v-bind Directive Example

In the previous example, we created Vue.js Hello World example using the text interpolation method in Vue.js. Here we will see Vue.js v-bind directive example to bind the HTML element to data. Directives in Vue.js are extended HTML attributes with the prefix v-. There are many directives provided by Vue.js and one of them is v-bind …

Read More

Vue.js Hello World Example

Vue.js Hello World Example

Vue Js Hello World Example is the best way to kick start the learning of Vuejs. Vue.js is the pure frontend development javascript library. It is becoming popular as a JS library for reactive components. It is lightweight, simple and focused on the view layer only. Other Vue.js tutorial Vue.js v-bind Directive Example Vue.js Conditional Directives …

Read More

How to convert String to Int in Java ?

How to convert String to Int in Java ?

To convert String to Int in Java, you can use the below methods of Integer class. Methods to convert String to Int 1) Integer.parseInt() code example /** * Created on Nov 19, 2016 Copyright(c) https://kodehelp.com All Rights Reserved. */ package com.kodehelp.java.lang; /** * @author https://kodehelp.com */ public class ConvertStringToInt { public static void main(String args[]){ …

Read More

Log4j2 Properties file examples

Log4j2 Properties file examples

Log4J2 Properties file configuration can be achieved in below 4 different file formats. Properties file format – log4j2.properties YAML file format – log4j2.yaml or log4j2.yml JSON file format – log4j2.json XML file format – log4j2.xml I don’t see many examples available for log4j 2 configuration. Here are the few examples of Log4j 2 configuration for your …

Read More

How to delete folder recursively on remote server using SFTP in java?

How to delete folder recursively on remote server using SFTP in java?

Deleting or removing a folder recursively on the remote server in java is easy using JSCH (SFTP) API. Nowadays it is a common use case in software projects where you need to delete or remove a folder from the remote server using SFTP connection. Below java code shows you how you can delete or remove …

Read More

How to delete file on remote server using SFTP in java?

How to delete file on remote server using SFTP in java?

Deleting or removing a file on remote server in java is easy using JSCH (SFTP) api. Now-a-days it is a common use case in software projects where you need to delete a file from the remote server using SFTP connection. JSch is a pure Java implementation of SSH2 (We can use SFTP Channel). JSch allows …

Read More

How to generate pseudorandom numbers in Java ?

How to generate pseudorandom numbers in Java ?

In this post we will see how to generate pseudorandom numbers in Java. Before that we will see what is Random numbers. Random numbers are the numbers that occur in sequence such that the values are uniformly distributed over a defined interval or set, which is impossible to predict future values based on present and …

Read More

Java Program For Uploading Folder Content recursively from local to SFTP Server

Java Program For Uploading Folder Content recursively from local to SFTP Server

Java program for uploading the content of a local machine directory or folder to SFTP server is not straight forward. If we use JSCH API for SFTP upload then you cannot use channelSftp.put(new FileInputStream(sourceFile), sourceFile.getName(), ChannelSftp.OVERWRITE); method. This channelSftp.put() method will work for single file upload but you cannot use it for folder upload. Below Java …

Read More

Working with Log4J Basics – A Log4J Tutorial

Introduction Here is your Basic Log4J tutorial helps you to setup Log4J in your application. Log statements placed in your code will work as a high level debugging mechanism for your application. Here I’m saying the logging mechanism as high level debugging mechanism, as low level debug mechanism is debugging the code step-by-step using IDE …

Read More

Java Program For Downloading Folder Content recursively from SFTP Server

Java Program For Downloading Folder Content recursively from SFTP Server

How to download folder from SFTP Server (Secure File Transfer Protocol) is the common use case for Java developer who wants to download folder from SFTP. To write a java program to download from SFTP, you will need to download JSCH jar file. For other SFTP operations in java, please refer below posts on Kodehelp.com – …

Read More

What is the difference between HashTable and HashMap in Java?

What is the difference between HashTable and HashMap in Java?

Both HashTable and HashMap are java collections and implements java.util.Map interface. Difference between HashTable and HashMap is the most common interview question. Many of the candidates who face the interview struggle to answer this question. Difference between HashTable and HashMap in Java Thread Safe: HashTable is thread-safe and can be shared between multiple threads but …

Read More