Author Archive


Automatic Backup of Compute Engine Persistent Disks in Google Cloud Platform

There are two ways to create a backup snapshot of compute engine persistent disks. You can either take a snapshot from the Google cloud console or run gcloud snapshot command from the command line.  The following command creates a snapshot (backup) of the disk named "mydisk1" created in "asia-east1-a" availability zone, gcloud compute disks snapshot […]

How to Copy Files from One Folder to Another in Java

The following Java program copies files with .java extension from one folder to another folder. You can easily change the extension .java to anything you want. For example, you might want to copy just .txt files from one directory to another. This program takes two input parameters. The first one is the source directory and […]

Array to Map Conversion in Java

Converting an array of strings to a map of strings with the same string as key and value is required in many use cases. Conversion to map enables quick and easy evaluation as to whether a string exists in the list of strings. Conversion to map also enables removal of duplicate strings. The following Java […]

How to Print a Number Pyramid in Java

The following Java program prints a sequential number pyramid in Java. The output of the program is given below.   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15   /** * Prints number pyramid Java * @author jj */ public class NumberPyramid { public static void main(String[] args) […]

Java Program to Find Repeated Words in a String

The following Java program prints repeated/duplicated words in a String. The program uses case insensitive comparison (For example, program assumes words CAT, cat and Cat etc. are all same). This algorithm is useful in text processing programs where word frequency calculations are needed. The program first asks for the input string from the command line. […]