Java Programming Tips

How to Generate Expires Value for Amazon S3 or Google Cloud Storage Using Java

Google Cloud Storage and Amazon S3 supports signed URLs for protected objects. Signed URLs can be used to enable temporary public access to protected content. Anyone with the signed URL can access the protected resource. However the validity of the signed URL is specified by a query parameter named Expires. This parameter specifies the validity […]

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. […]