Generate/create random GUID or UUID in java (JUG library/example)

Generate guid or uuid using RandomBasedGenerator class of Java UUID Generator (JUG) library. In current post, we will generate random uuid using JUG library. Generate random UUID using RandomBasedGenerator class in java. Generate custom random UUID using input random number in java. 1. Maven dependency of JUG library <dependency> <groupId>com.fasterxml.uuid</groupId> <artifactId>java-uuid-generator</artifactId> <version>3.1.3</version> </dependency> 2. Generate or… Read More »

Time based uuid generator in java (JUG library / example)

Generate time based uuid in java using JUG (Java Uuid Generator) library. JUG library provides couple of generator viz TimeBasedGenerator & RandomBasedGenerator. In current post, we will demonstrate TimeBasedGenerator of JUG library. Generate time based UUID using TimeBasedGenerator Get the timestamp of generated UUID. Generate custom UUID using network interface. Maven dependency of JUG library <dependency> <groupId>com.fasterxml.uuid</groupId> <artifactId>java-uuid-generator</artifactId> <version>3.1.3</version>… Read More »

Get IP Address from hostname (loopback, local & standard hosts) in java (example)

Given hostname in java, we would like to find out the corresponding IP address. We will discuss out the following scenarios: Input loopback hostname & get corresponding ip address. We will use API InetAddress.getLoopbackAddress() to get loopback address. Input local hostname & get local IP address. We will use API InetAddress.getLocalHost() to get local host… Read More »

List or display contents of compressed or zipped file in java (example)

Given a zipped or compressed file in java. We would like to display or list the contents of zipped file. We will display the name and size of uncompressed files. Program – list or display contents of zipped /compressed file in java package org.learn; import java.io.IOException; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; public class DisplayZipContents {… Read More »

Compress or zip directory (sub-directories) recursively – ZipOutputStream in java (example)

Given an input directory containing files and sub-directories. We would like to compress or zip all files present in a input directory. We will traverse input directory recursively to compress all files. Java framework has provided couple of classes to zip a file(s). ZipOutputStream: ZipOutputStream class implements an output stream filter for writing files in… Read More »

Create compress /zip file in java (ZipOutputStream class /example)

Given the input files in java, create zip or compress files using ZipOutputStream class . Java framework has provided couple of classes to create a zip & compress file. ZipOutputStream: ZipOutputStream class implements an output stream filter for writing files in ZIP file format. ZipEntry: ZipEntry class represents a ZIP file entry. e.g. If we want to… Read More »

Page 5 of 44« First...34567...102030...Last »