InitialDirContext lookup method

In this post under Java LDAP, I will show how to lookup for an entry in LDAP directory tree using ldap distinguished name. Below is the complete main class for your reference Main class 1 package package2; 2 3 import java.util.Hashtable; 4 5 import javax.naming.Context; 6 import javax.naming.NamingException; 7 import javax.naming.directory.DirContext; 8 import javax.naming.directory.InitialDirContext; 9…… Continue reading InitialDirContext lookup method

Connecting to LDAP server

In this post under Java LDAP, I will explain how to connect to LDAP server with an example. Below is the complete code Main Code 1 import java.util.Hashtable; 2 3 import javax.naming.Context; 4 import javax.naming.NamingException; 5 import javax.naming.directory.DirContext; 6 import javax.naming.directory.InitialDirContext; 7 8 public class LDAPDemo1 { 9 public static void main(String[] args) { 10…… Continue reading Connecting to LDAP server

Adding and accessing static members to Java Record

In this post under Java, I will show with example how to add and access static members in Java Record. Below is the structure of “Student” Record with static members Student 1 package core.record;2 3 public record Student(int id, String name, int age) {4 public static int noOfStudents;5 public static void display() {6 System.out.println(“Number of…… Continue reading Adding and accessing static members to Java Record

Creating text file of user specified size with random data

In this post under Java, I will show with example how to create a text file of user specified size with random data. Below is the complete code for you example Main class 1 package io;2 3 import java.io.BufferedWriter;4 import java.io.File;5 import java.io.FileWriter;6 import java.io.IOException;7 import java.util.Random;8 9 public class IOExample1 {10 private Random random;11…… Continue reading Creating text file of user specified size with random data

Uncompressing a gzip file

In this post under Java, I will show with example how to uncompress a gzip format file. For decompressing a gzip file, we will use java provided “GZIPInputStream” class. Below is the main code for your reference Main class 1 package zip; 2 3 import java.io.File; 4 import java.io.FileInputStream; 5 import java.io.FileOutputStream; 6 import java.io.IOException;…… Continue reading Uncompressing a gzip file