Inter thread communication in java (Example/ PipedInputStream /PipedOutputStream)

Inter thread communication is very common phenomenon. There are many ways to achieve inter thread communication. In current post, we will use pipes to achieve thread communication. Java has set of classes named PipedOutputStream & PipedInputStream to communicate between threads. We will create couple of threaders namely producer & consumer. Producer thread will produce the… Read More »

Create new file & folder (directory) in java (with example)

Given a path in java, create a new folder/directory & file using File class. File class has following methods to create file & directory in java. We will create directory in non existed path using mkdirs api. Also, we will create new directory & file using mkdir & createNewFile respectively. Program: create new file &… Read More »

Unzip or decompress files in java using ZipInputStream & ZipEntry (example)

Given a zipped or compressed file in java. Write a program to unzip or decompress the contents of zip file using ZipInputStream in java. Zip file may contain nested directory structure. e.g. Zip file may have compressed files having following directory structure. FirstFile.txt SecondFile.txt Dir1\Dir1_F1.txt Dir1\Dir1_F2.txt Dir1\Dir11\Dir11_F1.txt Dir1\Dir11\Dir11_F2.txt ….. Read the content of zip files… Read More »

Generate UUID or GUID from String in java (with example)

Given an string representing unique identifier. We would like to convert string to corresponding universal unique identifier (UUID) or Globally unique identifier (GUID). We will use java.util.UUID class to create UUID or GUID from string. e.g UUID generateUUID = UUID.fromString(inputUUID) Program: generate UUID or GUID from String in java package org.learn.uuid; import java.util.UUID; public class GenerateUUIDFromString {… Read More »

Generate unique identifier or UUID or GUID in java (with example)

Universal unique identifier (UUID) or Globally unique identifier (GUID) is unique identifier (or Id). GUID represents the unique id(s). Typically UUID is used in following scenarios: UUID is used as a primary key in database Window’s registry is using GUID (or UUID) to uniquely identify (installed) resources. GUID is also used to generate unique name… Read More »

Page 3 of 4212345...102030...Last »